Skip to content

use import pattern that supports windows external drives #983

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 13, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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