Skip to content

Commit a78727c

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

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

@@ -282,23 +282,23 @@ const generateCommand = defineCommand({
282282
},
283283
},
284284
run: async ({ args }) => {
285-
let customConfig = null;
286-
let customConfigPath: string | undefined;
285+
let customConfig;
287286

288287
if (args["custom-config"]) {
289288
try {
290-
customConfigPath = path.resolve(process.cwd(), args["custom-config"]);
291-
customConfig = await import(pathToFileURL(customConfigPath).toString());
289+
const customConfigPath = url
290+
.pathToFileURL(path.resolve(process.cwd(), args["custom-config"]))
291+
.toString();
292+
customConfig = await import(customConfigPath);
292293
customConfig = customConfig.default || customConfig;
294+
if (customConfig) {
295+
consola.info(`Found custom config at: ${customConfigPath}`);
296+
}
293297
} catch (error) {
294298
consola.error("Error loading custom config:", error);
295299
}
296300
}
297301

298-
if (customConfig) {
299-
consola.info(`Found custom config at: ${customConfigPath}`);
300-
}
301-
302302
await generateApi({
303303
addReadonly: args["add-readonly"],
304304
anotherArrayType: args["another-array-type"],

0 commit comments

Comments
 (0)