mirror of https://github.com/embarklabs/embark.git
fix plugin command
This commit is contained in:
parent
53de6dcb19
commit
2782acf438
|
@ -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');
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue