qat-cli 0.2.5 → 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 +41 -11
- 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.cjs
CHANGED
|
@@ -174,17 +174,20 @@ function clearConfigCache() {
|
|
|
174
174
|
}
|
|
175
175
|
async function importConfig(filePath) {
|
|
176
176
|
const { resolve } = await import("path");
|
|
177
|
+
const { pathToFileURL: pathToFileURL2 } = await import("url");
|
|
177
178
|
const absolutePath = resolve(process.cwd(), filePath);
|
|
178
179
|
if (!import_node_fs.default.existsSync(absolutePath)) {
|
|
179
180
|
throw new Error(`Cannot find module '${absolutePath}'`);
|
|
180
181
|
}
|
|
182
|
+
const fileUrl = pathToFileURL2(absolutePath).href;
|
|
181
183
|
try {
|
|
182
|
-
const module2 = await import(
|
|
184
|
+
const module2 = await import(fileUrl);
|
|
183
185
|
return module2.default || module2;
|
|
184
186
|
} catch {
|
|
185
187
|
const jsPath = absolutePath.replace(/\.ts$/, ".js");
|
|
186
|
-
if (import_node_fs.default.existsSync(jsPath)) {
|
|
187
|
-
const
|
|
188
|
+
if (jsPath !== absolutePath && import_node_fs.default.existsSync(jsPath)) {
|
|
189
|
+
const jsUrl = pathToFileURL2(jsPath).href;
|
|
190
|
+
const module2 = await import(jsUrl);
|
|
188
191
|
return module2.default || module2;
|
|
189
192
|
}
|
|
190
193
|
throw new Error(`\u65E0\u6CD5\u52A0\u8F7D\u914D\u7F6E\u6587\u4EF6: ${absolutePath}`);
|