From 1ad0095b4a1cba572ad2c50ef34b32897d28b2ff Mon Sep 17 00:00:00 2001 From: Robert Putnam Date: Wed, 18 Sep 2024 10:31:38 -0600 Subject: [PATCH] use import pattern that supports windows external drives --- index.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/index.js b/index.js index a920f2d0..1a0aa90e 100644 --- a/index.js +++ b/index.js @@ -1,6 +1,7 @@ #!/usr/bin/env node import { resolve } from "node:path"; +import { pathToFileURL } from "node:url"; import { cli } from "./cli/index.js"; import packageJson from "./package.json"; import { TemplatesGenConfig } from "./src/commands/generate-templates/configuration.js"; @@ -295,20 +296,21 @@ program.addCommand({ const main = async () => { const { command, options } = await program.execute({ args: process.argv }); - let customConfig = null; - let customConfigPath; + let customConfig; if (options.customConfig) { try { - customConfigPath = resolve(process.cwd(), options.customConfig); + const customConfigPath = pathToFileURL( + resolve(process.cwd(), options.customConfig), + ).toString(); customConfig = await import(customConfigPath); customConfig = customConfig.default || customConfig; + if (customConfig) { + console.log(`✨ found custom config at: ${customConfigPath}`); + } } catch (e) { console.error("Error loading custom config", e); } - if (customConfig) { - console.log(`✨ found custom config at: ${customConfigPath}`); - } } try {