Skip to content

Commit

Permalink
fix: handle exception cases while no plugins (#142)
Browse files Browse the repository at this point in the history
* chore: change report log to debug level (#139)

* chore: release v0.16.2

* chore: release v0.16.3

* docs(changelog): update changelog

* fix: handle exception cases while no plugins

* fix: handle exception cases while no plugins

* refactor: modify prompt message
  • Loading branch information
shanshandev authored and cpselvis committed Nov 25, 2019
1 parent 91b5b07 commit aed5b58
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions packages/feflow-cli/src/core/native/list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import chalk from 'chalk'
function loadModuleList(ctx: any) {
const packagePath = ctx.rootPkg;
const pluginDir = path.join(ctx.root, 'node_modules');
const extend = function (target:any, source:any) {
const extend = function (target: any, source: any) {
for (var obj in source) {
target[obj] = source[obj];
}
Expand All @@ -32,21 +32,37 @@ function loadModuleList(ctx: any) {
module.exports = (ctx: any) => {
ctx.commander.register('list', 'Show all plugins installed.', () => {
const list = loadModuleList(ctx);
let templateCnt = 0;
let pluginCnt = 0;

console.log('You can search more templates or plugins through https://feflowjs.com/encology/');
console.log('===============================================');
if (!list.length) {
console.log(chalk.magenta('No templates and plugins have been installed'));
return;
}

console.log('templates');
list.map(function (name) {
if (!/generator-|^@[^/]+\/generator-/.test(name)){
if (/generator-|^@[^/]+\/generator-/.test(name)) {
console.log(chalk.magenta(name));
templateCnt = 1;
}
});
if (!templateCnt) {
console.log(chalk.magenta('No templates have been installed'));
}

console.log('plugins');
list.map(function (name) {
if (!/^feflow-plugin-|^@[^/]+\/feflow-plugin-/.test(name)) {
if (/^feflow-plugin-|^@[^/]+\/feflow-plugin-/.test(name)) {
console.log(chalk.magenta(name));
pluginCnt = 1;
}
});
if (!pluginCnt) {
console.log(chalk.magenta('No plugins have been installed'));
}
});
};

0 comments on commit aed5b58

Please sign in to comment.