Skip to content

Commit

Permalink
use import pattern that supports windows external drives
Browse files Browse the repository at this point in the history
  • Loading branch information
thechucklingatom authored and smorimoto committed Nov 13, 2024
1 parent da2e3f0 commit 1ad0095
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions index.js
Original file line number Diff line number Diff line change
@@ -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";
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 1ad0095

Please sign in to comment.