Skip to content

Commit

Permalink
fix: run commands error when in a feflow project but not installed de…
Browse files Browse the repository at this point in the history
…vkit (#159)

close #157
  • Loading branch information
cpselvis authored Nov 28, 2019
1 parent 39d021b commit a7b987d
Showing 1 changed file with 19 additions and 15 deletions.
34 changes: 19 additions & 15 deletions packages/feflow-cli/src/core/devkit/loadDevkits.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,25 @@ const registerDevkitCommand = (command: any, commandConfig: any, directoryPath:
const builder = commandConfig.builder;
const [ packageName ] = builder.split(':', 2);
const pkgPath = path.join(directoryPath, 'node_modules', packageName);
const kitJson = require(path.join(pkgPath, 'devkit.json'));
const { implementation, description } = kitJson.builders[command];

if (Array.isArray(implementation)) {
ctx.commander.register(command, description, async () => {
for (let i = 0; i < implementation.length; i ++) {
const action = path.join(pkgPath, implementation[i]);
await require(action)(ctx);
}
});
} else {
const action = path.join(pkgPath, implementation);
ctx.commander.register(command, description, () => {
require(action)(ctx);
});
let kitJson;
try {
kitJson = require(path.join(pkgPath, 'devkit.json'));
const { implementation, description } = kitJson.builders[command];
if (Array.isArray(implementation)) {
ctx.commander.register(command, description, async () => {
for (let i = 0; i < implementation.length; i ++) {
const action = path.join(pkgPath, implementation[i]);
await require(action)(ctx);
}
});
} else {
const action = path.join(pkgPath, implementation);
ctx.commander.register(command, description, () => {
require(action)(ctx);
});
}
} catch (e) {
ctx.logger.debug(`${ pkgPath } not found!`);
}
};

Expand Down

0 comments on commit a7b987d

Please sign in to comment.