Skip to content

use import pattern that supports windows external drives #930

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 2 commits into from
Oct 29, 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
15 changes: 8 additions & 7 deletions index.ts
Original file line number Diff line number Diff line change
@@ -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" };
Expand Down Expand Up @@ -276,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"]);
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"],
Expand Down