changes from the code review

This commit is contained in:
Subramanian Venkatesan 2018-09-10 22:38:17 +05:30
parent 2782acf438
commit fe0bbc3559
4 changed files with 10 additions and 16 deletions

View File

@ -127,6 +127,7 @@ class EmbarkController {
engine.startService("codeGenerator");
engine.startService("namingSystem");
engine.startService("console");
engine.startService("pluginCommand");
engine.events.on('check:backOnline:Ethereum', function () {
engine.logger.info(__('Ethereum node detected') + '..');

View File

@ -132,7 +132,7 @@ class Engine {
}
pluginCommandService() {
this.registerModule('plugin_cmd', {embarkConfigFile: this.embarkConfig, packageFile: 'package.json'});
this.registerModule('plugin_cmd', {embarkConfigFile: this.embarkConfig, embarkConfig: this.config.embarkConfig, packageFile: 'package.json'});
}
namingSystem(_options) {

View File

@ -5,7 +5,7 @@ class PluginCommand {
constructor(embark, config) {
this.embark = embark;
this.config = config;
this.embarkConfig = fs.readJSONSync(this.config.embarkConfigFile);
this.embarkConfig = this.config.embarkConfig;
this.registerCommand();
}
registerCommand() {
@ -20,16 +20,8 @@ class PluginCommand {
if(cmdArray.length < 3 || cmdArray[1] !== 'install' || typeof cmdArray[2] === 'undefined') {
return callback('invalid use of plugin command. Please use plugin install <package>');
}
let npmInstall = ['npm', 'install'];
if (cmdArray[2] === '--save') {
if(typeof cmdArray[3] === 'undefined') {
return callback('package argument missing');
}
} else {
npmInstall.push('--save');
}
let npmInstall = ['npm', 'install', '--save'];
npmInstall = npmInstall.concat(cmdArray.slice(2));
async.waterfall([
function npmInstallAsync(cb) {
utils.runCmd(npmInstall.join(' '), {silent: false, exitOnError: false}, (err) => {
@ -50,10 +42,9 @@ class PluginCommand {
}
], (err) => {
if(err) {
callback(err);
} else {
callback(null, 'npm package successfully installed as a plugin');
return callback(err);
}
callback(null, 'npm package successfully installed as a plugin');
});
}
};

View File

@ -143,10 +143,12 @@ function runCmd(cmd, options, callback) {
return callback(result, null);
}
if (options.exitOnError) {
exit();
return exit();
}
}
callback(null, result);
if(typeof callback === 'function') {
return callback(null, result);
}
}
function cd(folder) {