Skip to content

Commit

Permalink
Remove auto prefix plugin name (#2757)
Browse files Browse the repository at this point in the history
* Remove auto prefix plugin name

* Remove unused function

* Cleanup
  • Loading branch information
albinekb committed Mar 13, 2018
1 parent e4cef0a commit 943211b
Showing 1 changed file with 11 additions and 18 deletions.
29 changes: 11 additions & 18 deletions cli/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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)));
});

Expand Down Expand Up @@ -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);
});

Expand Down

0 comments on commit 943211b

Please sign in to comment.