|
1 | 1 | import * as path from "node:path"; |
| 2 | +import * as url from "node:url"; |
2 | 3 | import { defineCommand, runMain } from "citty"; |
3 | 4 | import { consola } from "consola"; |
4 | 5 | import packageJson from "./package.json" with { type: "json" }; |
5 | 6 | import { TemplatesGenConfig } from "./src/commands/generate-templates/configuration.js"; |
6 | 7 | import { CodeGenConfig } from "./src/configuration.js"; |
7 | 8 | import { HTTP_CLIENT } from "./src/constants.js"; |
8 | 9 | import { generateApi, generateTemplates } from "./src/index.js"; |
9 | | -import { pathToFileURL } from "url"; |
10 | 10 |
|
11 | 11 | const templateGenBaseConfig = new TemplatesGenConfig({}); |
12 | 12 |
|
@@ -277,23 +277,23 @@ const generateCommand = defineCommand({ |
277 | 277 | if (args.debug) consola.level = Number.MAX_SAFE_INTEGER; |
278 | 278 | if (args.silent) consola.level = 0; |
279 | 279 |
|
280 | | - let customConfig = null; |
281 | | - let customConfigPath: string | undefined; |
| 280 | + let customConfig; |
282 | 281 |
|
283 | 282 | if (args["custom-config"]) { |
284 | 283 | try { |
285 | | - customConfigPath = path.resolve(process.cwd(), args["custom-config"]); |
286 | | - customConfig = await import(pathToFileURL(customConfigPath).toString()); |
| 284 | + const customConfigPath = url |
| 285 | + .pathToFileURL(path.resolve(process.cwd(), args["custom-config"])) |
| 286 | + .toString(); |
| 287 | + customConfig = await import(customConfigPath); |
287 | 288 | customConfig = customConfig.default || customConfig; |
| 289 | + if (customConfig) { |
| 290 | + consola.info(`Found custom config at: ${customConfigPath}`); |
| 291 | + } |
288 | 292 | } catch (error) { |
289 | 293 | consola.error("Error loading custom config:", error); |
290 | 294 | } |
291 | 295 | } |
292 | 296 |
|
293 | | - if (customConfig) { |
294 | | - consola.info(`Found custom config at: ${customConfigPath}`); |
295 | | - } |
296 | | - |
297 | 297 | await generateApi({ |
298 | 298 | addReadonly: args["add-readonly"], |
299 | 299 | anotherArrayType: args["another-array-type"], |
|
0 commit comments