diff --git a/index.ts b/index.ts index 2006ff18..d29e1aed 100644 --- a/index.ts +++ b/index.ts @@ -1,4 +1,5 @@ import * as path from "node:path"; +import * as url from "node:url"; import { defineCommand, runMain } from "citty"; import { consola } from "consola"; import packageJson from "./package.json" with { type: "json" }; @@ -276,23 +277,23 @@ const generateCommand = defineCommand({ if (args.debug) consola.level = Number.MAX_SAFE_INTEGER; if (args.silent) consola.level = 0; - let customConfig = null; - let customConfigPath: string | undefined; + let customConfig; if (args["custom-config"]) { try { - customConfigPath = path.resolve(process.cwd(), args["custom-config"]); + const customConfigPath = url + .pathToFileURL(path.resolve(process.cwd(), args["custom-config"])) + .toString(); customConfig = await import(customConfigPath); customConfig = customConfig.default || customConfig; + if (customConfig) { + consola.info(`Found custom config at: ${customConfigPath}`); + } } catch (error) { consola.error("Error loading custom config:", error); } } - if (customConfig) { - consola.info(`Found custom config at: ${customConfigPath}`); - } - await generateApi({ addReadonly: args["add-readonly"], anotherArrayType: args["another-array-type"],