Skip to content

Commit

Permalink
refactor: update JsonFileConfig export and usage
Browse files Browse the repository at this point in the history
  • Loading branch information
zimuya4153 committed Jan 3, 2025
1 parent f4f74bf commit 9d8ee00
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
5 changes: 4 additions & 1 deletion lib/shortcutApi/JsonFileConfig.d.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
/// <reference path="../dts/index.d.ts"/>

export default function JsonFileConfig<T>(
export function JsonFileConfig<T>(
/** 文件路径 */
path: string,
/** 默认内容 */
defaultConfig: T,
/** 缩进 */
space?: number | string
): T | Record<string, any>;
6 changes: 2 additions & 4 deletions lib/shortcutApi/JsonFileConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,5 @@ function JsonFileConfig(path, defaultConfig, space = 4) {
return new Proxy(content ?? defaultConfig ?? {}, handler);
}

export default JsonFileConfig;

const isCjs = typeof module === "object" && typeof module.exports === "object";
if (isCjs) module.exports = JsonFileConfig;
export { JsonFileConfig };
if (typeof this?.module?.exports === "object") module.exports = JsonFileConfig;
3 changes: 1 addition & 2 deletions test/test_js_plugin.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/// <reference path="../js_engine/dts/index.d.ts"/>

/** @type {import("../js_engine/shortcutApi/JsonFileConfig.js")["default"]} */
// const JsonFileConfig = require("../js_engine/shortcutApi/JsonFileConfig.js")["default"];
// const { JsonFileConfig } = require("../js_engine/shortcutApi/JsonFileConfig.js");

import { b } from "./b.js";
b();
Expand Down

0 comments on commit 9d8ee00

Please sign in to comment.