Skip to content

Commit

Permalink
Merge pull request #983 from acacode/backport-930
Browse files Browse the repository at this point in the history
use import pattern that supports windows external drives
  • Loading branch information
smorimoto authored Nov 13, 2024
2 parents da2e3f0 + 1ad0095 commit b009465
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 b009465

Please sign in to comment.