From c53600df8bdd208c00bff21491f9e21785797cdb Mon Sep 17 00:00:00 2001 From: Robert Putnam Date: Wed, 18 Sep 2024 10:31:38 -0600 Subject: [PATCH 1/2] use import pattern that supports windows external drives --- index.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/index.ts b/index.ts index 2006ff18..2e00f681 100644 --- a/index.ts +++ b/index.ts @@ -6,6 +6,7 @@ import { TemplatesGenConfig } from "./src/commands/generate-templates/configurat import { CodeGenConfig } from "./src/configuration.js"; import { HTTP_CLIENT } from "./src/constants.js"; import { generateApi, generateTemplates } from "./src/index.js"; +import { pathToFileURL } from "url"; const templateGenBaseConfig = new TemplatesGenConfig({}); @@ -282,7 +283,7 @@ const generateCommand = defineCommand({ if (args["custom-config"]) { try { customConfigPath = path.resolve(process.cwd(), args["custom-config"]); - customConfig = await import(customConfigPath); + customConfig = await import(pathToFileURL(customConfigPath).toString()); customConfig = customConfig.default || customConfig; } catch (error) { consola.error("Error loading custom config:", error); From dd46e5efbcce337c17cad89ab5d5d3a951a552bb Mon Sep 17 00:00:00 2001 From: Sora Morimoto Date: Tue, 29 Oct 2024 20:33:54 +0900 Subject: [PATCH 2/2] Cleanup Signed-off-by: Sora Morimoto --- index.ts | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/index.ts b/index.ts index 2e00f681..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" }; @@ -6,7 +7,6 @@ import { TemplatesGenConfig } from "./src/commands/generate-templates/configurat import { CodeGenConfig } from "./src/configuration.js"; import { HTTP_CLIENT } from "./src/constants.js"; import { generateApi, generateTemplates } from "./src/index.js"; -import { pathToFileURL } from "url"; const templateGenBaseConfig = new TemplatesGenConfig({}); @@ -277,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"]); - customConfig = await import(pathToFileURL(customConfigPath).toString()); + 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"],