Skip to content

Commit 9af7d5d

Browse files
authored
Merge pull request #504 from BrianTo176/master
Add more option for custom config [#503]
2 parents 418e5cd + 56a8e1a commit 9af7d5d

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

index.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,11 @@ const program = cli({
238238
description: 'sort routes in alphabetical order',
239239
default: codeGenBaseConfig.sortRoutes,
240240
},
241+
{
242+
flags: "--custom-config <string>",
243+
description: "custom config: primitiveTypeConstructs, hooks, ... ",
244+
default: '',
245+
}
241246
],
242247
});
243248

@@ -292,16 +297,30 @@ program.addCommand({
292297
const main = async () => {
293298
const { command, options } = await program.execute({ args: process.argv });
294299

300+
let customConfig = null
301+
302+
if (options.customConfig) {
303+
try {
304+
const customConfigPath = resolve(process.cwd(), options.customConfig)
305+
console.log(`✨ found custom config at: ${customConfigPath}`)
306+
customConfig = require(customConfigPath)
307+
} catch (e) {}
308+
}
309+
295310
try {
296311
switch (command) {
297312
case null: {
298313
await generateApi({
299314
...options,
315+
name: options.name,
316+
url: options.path,
317+
generateRouteTypes: options.routeTypes,
300318
generateClient: !!(options.axios || options.client),
301319
httpClientType: options.axios ? HTTP_CLIENT.AXIOS : HTTP_CLIENT.FETCH,
302320
url: options.path,
303321
input: resolve(process.cwd(), options.path),
304322
output: resolve(process.cwd(), options.output || '.'),
323+
...customConfig,
305324
});
306325
break;
307326
}

0 commit comments

Comments
 (0)