Skip to content

Commit dd46e5e

Browse files
committed
Cleanup
Signed-off-by: Sora Morimoto <[email protected]>
1 parent c53600d commit dd46e5e

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

index.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import * as path from "node:path";
2+
import * as url from "node:url";
23
import { defineCommand, runMain } from "citty";
34
import { consola } from "consola";
45
import packageJson from "./package.json" with { type: "json" };
56
import { TemplatesGenConfig } from "./src/commands/generate-templates/configuration.js";
67
import { CodeGenConfig } from "./src/configuration.js";
78
import { HTTP_CLIENT } from "./src/constants.js";
89
import { generateApi, generateTemplates } from "./src/index.js";
9-
import { pathToFileURL } from "url";
1010

1111
const templateGenBaseConfig = new TemplatesGenConfig({});
1212

@@ -277,23 +277,23 @@ const generateCommand = defineCommand({
277277
if (args.debug) consola.level = Number.MAX_SAFE_INTEGER;
278278
if (args.silent) consola.level = 0;
279279

280-
let customConfig = null;
281-
let customConfigPath: string | undefined;
280+
let customConfig;
282281

283282
if (args["custom-config"]) {
284283
try {
285-
customConfigPath = path.resolve(process.cwd(), args["custom-config"]);
286-
customConfig = await import(pathToFileURL(customConfigPath).toString());
284+
const customConfigPath = url
285+
.pathToFileURL(path.resolve(process.cwd(), args["custom-config"]))
286+
.toString();
287+
customConfig = await import(customConfigPath);
287288
customConfig = customConfig.default || customConfig;
289+
if (customConfig) {
290+
consola.info(`Found custom config at: ${customConfigPath}`);
291+
}
288292
} catch (error) {
289293
consola.error("Error loading custom config:", error);
290294
}
291295
}
292296

293-
if (customConfig) {
294-
consola.info(`Found custom config at: ${customConfigPath}`);
295-
}
296-
297297
await generateApi({
298298
addReadonly: args["add-readonly"],
299299
anotherArrayType: args["another-array-type"],

0 commit comments

Comments
 (0)