|
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 |
|
@@ -282,23 +282,23 @@ const generateCommand = defineCommand({
|
282 | 282 | },
|
283 | 283 | },
|
284 | 284 | run: async ({ args }) => {
|
285 |
| - let customConfig = null; |
286 |
| - let customConfigPath: string | undefined; |
| 285 | + let customConfig; |
287 | 286 |
|
288 | 287 | if (args["custom-config"]) {
|
289 | 288 | try {
|
290 |
| - customConfigPath = path.resolve(process.cwd(), args["custom-config"]); |
291 |
| - customConfig = await import(pathToFileURL(customConfigPath).toString()); |
| 289 | + const customConfigPath = url |
| 290 | + .pathToFileURL(path.resolve(process.cwd(), args["custom-config"])) |
| 291 | + .toString(); |
| 292 | + customConfig = await import(customConfigPath); |
292 | 293 | customConfig = customConfig.default || customConfig;
|
| 294 | + if (customConfig) { |
| 295 | + consola.info(`Found custom config at: ${customConfigPath}`); |
| 296 | + } |
293 | 297 | } catch (error) {
|
294 | 298 | consola.error("Error loading custom config:", error);
|
295 | 299 | }
|
296 | 300 | }
|
297 | 301 |
|
298 |
| - if (customConfig) { |
299 |
| - consola.info(`Found custom config at: ${customConfigPath}`); |
300 |
| - } |
301 |
| - |
302 | 302 | await generateApi({
|
303 | 303 | addReadonly: args["add-readonly"],
|
304 | 304 | anotherArrayType: args["another-array-type"],
|
|
0 commit comments