Skip to content

Commit

Permalink
feat(init): support initialize project with selected generator
Browse files Browse the repository at this point in the history
  • Loading branch information
fXy-during committed Feb 27, 2020
1 parent 9565309 commit fff9b24
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
14 changes: 13 additions & 1 deletion packages/feflow-cli/src/core/native/generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,23 @@ const run = (ctx: any, name: string) => {

module.exports = (ctx: any) => {
ctx.commander.register('init', 'Create a new project', () => {
const { root, rootPkg } = ctx;
const { root, rootPkg, args } = ctx;
const { g, generator } = args;
const chooseGenerator = g || generator;
let chooseGeneratorIsValid = false;

loadGenerator(root, rootPkg).then((generators: any) => {
const options = generators.map((item: any) => {
if (item.name === chooseGenerator) {
chooseGeneratorIsValid = true
}
return item.desc
});

if(chooseGeneratorIsValid) {
return run(ctx, chooseGenerator);
}

if (generators.length) {
inquirer.prompt([{
type: 'list',
Expand Down
3 changes: 2 additions & 1 deletion packages/feflow-cli/types/index.d.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
declare module '@feflow/report';
declare module '@feflow/report';
declare module "request-promise"

0 comments on commit fff9b24

Please sign in to comment.