Skip to content

Commit

Permalink
Merge pull request #189 from Tencent/feat_init_args
Browse files Browse the repository at this point in the history
feat(init): support initialize project with selected generator
  • Loading branch information
cpselvis authored Feb 29, 2020
2 parents 9565309 + 1d91a32 commit 763eab5
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 { generator } = args;
const chooseGenerator = generator;
let isValidGenerator = false;

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

if(isValidGenerator) {
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 763eab5

Please sign in to comment.