fix plugin command

This commit is contained in:
Subramanian Venkatesan 2018-09-10 18:25:17 +05:30
parent 53de6dcb19
commit 2782acf438
1 changed files with 5 additions and 5 deletions

View File

@ -6,9 +6,9 @@ class PluginCommand {
this.embark = embark; this.embark = embark;
this.config = config; this.config = config;
this.embarkConfig = fs.readJSONSync(this.config.embarkConfigFile); this.embarkConfig = fs.readJSONSync(this.config.embarkConfigFile);
this.registerCommands(); this.registerCommand();
} }
registerCommands() { registerCommand() {
const self = this; const self = this;
self.embark.registerConsoleCommand((cmd, _options) => { self.embark.registerConsoleCommand((cmd, _options) => {
let cmdArray = cmd.split(' '); let cmdArray = cmd.split(' ');
@ -18,12 +18,12 @@ class PluginCommand {
match: () => cmdName === 'plugin', match: () => cmdName === 'plugin',
process: (callback) => { process: (callback) => {
if(cmdArray.length < 3 || cmdArray[1] !== 'install' || typeof cmdArray[2] === 'undefined') { if(cmdArray.length < 3 || cmdArray[1] !== 'install' || typeof cmdArray[2] === 'undefined') {
return callback(__('arguments to the command are missing or invalid')); return callback('invalid use of plugin command. Please use plugin install <package>');
} }
let npmInstall = ['npm', 'install']; let npmInstall = ['npm', 'install'];
if (cmdArray[2] === '--save') { if (cmdArray[2] === '--save') {
if(typeof cmdArray[3] === 'undefined') { if(typeof cmdArray[3] === 'undefined') {
return callback(__('npm package argument missing')); return callback('package argument missing');
} }
} else { } else {
npmInstall.push('--save'); npmInstall.push('--save');
@ -50,7 +50,7 @@ class PluginCommand {
} }
], (err) => { ], (err) => {
if(err) { if(err) {
callback(__(err)); callback(err);
} else { } else {
callback(null, 'npm package successfully installed as a plugin'); callback(null, 'npm package successfully installed as a plugin');
} }