diff --git a/cli/index.js b/cli/index.js index 5f631608bf0b..2cecddc92d3a 100644 --- a/cli/index.js +++ b/cli/index.js @@ -23,13 +23,6 @@ const assertPluginName = pluginName => { } }; -const getPluginName = arg => { - if (arg.indexOf(PLUGIN_PREFIX) !== 0) { - return `${PLUGIN_PREFIX}${arg}`; - } - return arg; -}; - const checkConfig = () => { if (api.exists()) { return true; @@ -42,21 +35,21 @@ const checkConfig = () => { args.command(['i', 'install'], 'Install a plugin', (name, args_) => { checkConfig(); - assertPluginName(args_[0]); - const plugin = getPluginName(args_[0]); + const pluginName = args_[0]; + assertPluginName(pluginName); commandPromise = api - .install(plugin) - .then(() => console.log(chalk.green(`${plugin} installed successfully!`))) + .install(pluginName) + .then(() => console.log(chalk.green(`${pluginName} installed successfully!`))) .catch(err => console.error(chalk.red(err))); }); args.command(['u', 'uninstall', 'rm', 'remove'], 'Uninstall a plugin', (name, args_) => { checkConfig(); - assertPluginName(args_[0]); - const plugin = getPluginName(args_[0]); + const pluginName = args_[0]; + assertPluginName(pluginName); commandPromise = api - .uninstall(plugin) - .then(() => console.log(chalk.green(`${plugin} uninstalled successfully!`))) + .uninstall(pluginName) + .then(() => console.log(chalk.green(`${pluginName} uninstalled successfully!`))) .catch(err => console.log(chalk.red(err))); }); @@ -134,9 +127,9 @@ args.command(['lsr', 'list-remote', 'ls-remote'], 'List plugins available on npm }); args.command(['d', 'docs', 'h', 'home'], 'Open the npm page of a plugin', (name, args_) => { - assertPluginName(args_[0]); - const plugin = getPluginName(args_[0]); - opn(`http://ghub.io/${plugin}`, {wait: false}); + const pluginName = args_[0]; + assertPluginName(pluginName); + opn(`http://ghub.io/${pluginName}`, {wait: false}); process.exit(0); });