Skip to content

Commit 3dc34a9

Browse files
committed
🔧 chore(app): 支持 codeg.config.mjs 配置文件
1 parent 923804a commit 3dc34a9

File tree

3 files changed

+22
-11
lines changed

3 files changed

+22
-11
lines changed

codeg.config.mjs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { defineConfig } from "./dist/index.mjs";
2+
3+
export default defineConfig({
4+
commands: {
5+
gituser: {
6+
ruleEmail: "^[a-zA-Z0-9._%+-]+@(gmail)\\.(com)$",
7+
},
8+
fix: {
9+
paths: ["./src", "./scripts"],
10+
},
11+
format: {
12+
paths: ["./src", "./scripts"],
13+
},
14+
impsort: {
15+
paths: ["./src", "./scripts"],
16+
},
17+
},
18+
});

src/config.ts

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -272,11 +272,4 @@ export const commands = [
272272
},
273273
];
274274

275-
export const DEFAULT_CONFIG_FILES = [
276-
"codeg.config.js",
277-
"codeg.config.mjs",
278-
"codeg.config.ts",
279-
"codeg.config.mts",
280-
"codeg.config.cjs",
281-
"codeg.config.cts",
282-
];
275+
export const DEFAULT_CONFIG_FILES = ["codeg.config.js", "codeg.config.mjs"];

src/helper.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import fs from "node:fs";
22
import path from "node:path";
33
import process from "node:process";
4+
import { pathToFileURL } from "node:url";
45

56
import boxen from "boxen";
67
import { CAC } from "cac";
@@ -212,7 +213,7 @@ export const getEveryFilesBySuffixes = async (
212213
"--diff-filter=d",
213214
"--cached",
214215
]);
215-
files = result?.split("\n").map((path) => `${cwd}/${path}`) || [];
216+
files = result?.split("\n").map((path: string) => `${cwd}/${path}`) || [];
216217
} else {
217218
files = getEveryFiles(paths.map((path) => `${cwd}/${path}`));
218219
}
@@ -378,6 +379,5 @@ export async function loadConfigModule(): Promise<
378379
}
379380

380381
if (!resolvedPath) return;
381-
382-
return (await import(resolvedPath)).default;
382+
return (await import(pathToFileURL(resolvedPath).href)).default;
383383
}

0 commit comments

Comments
 (0)