qat-cli 0.2.6 → 0.2.7
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/README.md +1 -1
- package/dist/cli.js +7 -4
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +6 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +6 -3
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -83,17 +83,20 @@ function clearConfigCache() {
|
|
|
83
83
|
}
|
|
84
84
|
async function importConfig(filePath) {
|
|
85
85
|
const { resolve } = await import("path");
|
|
86
|
+
const { pathToFileURL: pathToFileURL2 } = await import("url");
|
|
86
87
|
const absolutePath = resolve(process.cwd(), filePath);
|
|
87
88
|
if (!fs.existsSync(absolutePath)) {
|
|
88
89
|
throw new Error(`Cannot find module '${absolutePath}'`);
|
|
89
90
|
}
|
|
91
|
+
const fileUrl = pathToFileURL2(absolutePath).href;
|
|
90
92
|
try {
|
|
91
|
-
const module = await import(
|
|
93
|
+
const module = await import(fileUrl);
|
|
92
94
|
return module.default || module;
|
|
93
95
|
} catch {
|
|
94
96
|
const jsPath = absolutePath.replace(/\.ts$/, ".js");
|
|
95
|
-
if (fs.existsSync(jsPath)) {
|
|
96
|
-
const
|
|
97
|
+
if (jsPath !== absolutePath && fs.existsSync(jsPath)) {
|
|
98
|
+
const jsUrl = pathToFileURL2(jsPath).href;
|
|
99
|
+
const module = await import(jsUrl);
|
|
97
100
|
return module.default || module;
|
|
98
101
|
}
|
|
99
102
|
throw new Error(`\u65E0\u6CD5\u52A0\u8F7D\u914D\u7F6E\u6587\u4EF6: ${absolutePath}`);
|