@shuiyangsuan/cli 0.0.1 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -8840,7 +8840,13 @@ async function collectFilesToDelete(patterns, _options) {
8840
8840
 
8841
8841
  //#endregion
8842
8842
  //#region src/config/index.ts
8843
- const CONFIG_FILES = [".clirc.json", ".clirc"];
8843
+ const CONFIG_FILES = [
8844
+ ".clirc.json",
8845
+ ".clrc",
8846
+ ".clirc.js",
8847
+ ".clirc.ts",
8848
+ ".clirc.mts"
8849
+ ];
8844
8850
  /**
8845
8851
  * 读取配置文件
8846
8852
  * @returns 配置对象
@@ -8849,9 +8855,17 @@ async function readConfig() {
8849
8855
  const cwd = process.cwd();
8850
8856
  for (const configFile of CONFIG_FILES) {
8851
8857
  const configPath = join(cwd, configFile);
8852
- if (existsSync(configPath)) try {
8853
- const content = readFileSync(configPath, "utf-8");
8854
- return JSON.parse(content);
8858
+ if (!existsSync(configPath)) continue;
8859
+ try {
8860
+ let config;
8861
+ if (configFile.endsWith(".json")) {
8862
+ const content = readFileSync(configPath, "utf-8");
8863
+ config = JSON.parse(content);
8864
+ } else {
8865
+ const module = await import(configPath);
8866
+ config = module.default || module;
8867
+ }
8868
+ return config;
8855
8869
  } catch (err) {
8856
8870
  console.warn(`读取配置文件失败 (${configFile}): ${err.message}`);
8857
8871
  }