Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove auto prefix plugin name #2757

Merged
merged 3 commits into from
Mar 13, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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