Skip to content

Commit

Permalink
Refactor plugin a bit.
Browse files Browse the repository at this point in the history
Signed-off-by: Eric Wang <skygragon@gmail.com>
  • Loading branch information
skygragon committed Dec 26, 2017
1 parent 3336663 commit a25cfa7
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions lib/commands/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,25 +65,25 @@ cmd.handler = function(argv) {
if (plugins.length === 0) return log.error('Plugin not found!');

var plugin = plugins[0];
var oldname = h.getPluginFile(plugin.file);
var fullpath = h.getPluginFile(plugin.file);
var newname;

if (argv.enable) {
if (plugin.file[0] !== '.') return;
if (plugin.enabled) return;
newname = h.getPluginFile(plugin.file.substr(1));

fs.rename(oldname, newname, function(e) {
fs.rename(fullpath, newname, function(e) {
if (e) log.error(e.message);
});
} else if (argv.disable) {
if (plugin.file[0] === '.') return;
if (!plugin.enabled) return;
newname = h.getPluginFile('.' + plugin.file);

fs.rename(oldname, newname, function(e) {
fs.rename(fullpath, newname, function(e) {
if (e) log.error(e.message);
});
} else if (argv.delete) {
fs.unlink(oldname, function(e) {
fs.unlink(fullpath, function(e) {
if (e) log.error(e.message);
});
} else if (argv.config) {
Expand Down

0 comments on commit a25cfa7

Please sign in to comment.