Skip to content

Commit

Permalink
feat(devtool): copy templates according to user input
Browse files Browse the repository at this point in the history
  • Loading branch information
cpselvis committed Jan 16, 2020
1 parent 4c98456 commit 7557299
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions packages/feflow-plugin-devtool/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import inquirer from 'inquirer';
import fs from 'fs-extra';
import path from 'path';


enum DEVTOOL_TYPE {
Expand All @@ -11,6 +13,8 @@ module.exports = (ctx: any) => {
const { args, commander, logger } = ctx;
const [ action ] = args['_'];

let templatePath: string;

commander.register('devtool', 'Feflow devtool for better develop a devkit or plugin', async () => {
switch (action) {
case 'init':
Expand All @@ -31,12 +35,15 @@ module.exports = (ctx: any) => {
switch (type) {
case DEVTOOL_TYPE.SCAFFLOAD:
message = '以 generator- 开头';
templatePath = path.join(__dirname, '../templates/generator-template');
break;
case DEVTOOL_TYPE.DEVKIT:
message = '以 feflow-devkit- 开头';
templatePath = path.join(__dirname, '../templates/devkit-template');
break;
case DEVTOOL_TYPE.PLUGIN:
message = '以 feflow-plugin- 开头';
templatePath = path.join(__dirname, '../templates/plugin-template');
break;
}

Expand All @@ -62,7 +69,9 @@ module.exports = (ctx: any) => {
}
}]);

console.log('name', name);
logger.info('Start creating %s', name);
const destinationPath = path.join(process.cwd(), name);
fs.copySync(templatePath, destinationPath);

break;
case 'dev':
Expand All @@ -72,4 +81,4 @@ module.exports = (ctx: any) => {
return null;
}
});
};
};

0 comments on commit 7557299

Please sign in to comment.