Skip to content

Commit fff9b24

Browse files
committed
feat(init): support initialize project with selected generator
1 parent 9565309 commit fff9b24

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

packages/feflow-cli/src/core/native/generator.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,23 @@ const run = (ctx: any, name: string) => {
5151

5252
module.exports = (ctx: any) => {
5353
ctx.commander.register('init', 'Create a new project', () => {
54-
const { root, rootPkg } = ctx;
54+
const { root, rootPkg, args } = ctx;
55+
const { g, generator } = args;
56+
const chooseGenerator = g || generator;
57+
let chooseGeneratorIsValid = false;
58+
5559
loadGenerator(root, rootPkg).then((generators: any) => {
5660
const options = generators.map((item: any) => {
61+
if (item.name === chooseGenerator) {
62+
chooseGeneratorIsValid = true
63+
}
5764
return item.desc
5865
});
66+
67+
if(chooseGeneratorIsValid) {
68+
return run(ctx, chooseGenerator);
69+
}
70+
5971
if (generators.length) {
6072
inquirer.prompt([{
6173
type: 'list',

packages/feflow-cli/types/index.d.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
declare module '@feflow/report';
1+
declare module '@feflow/report';
2+
declare module "request-promise"

0 commit comments

Comments
 (0)