From f201b310c3e4edc69fdc1c6661dbb0fcb30c04be Mon Sep 17 00:00:00 2001 From: Henrique Vicente Date: Mon, 22 Jun 2015 20:45:50 -0300 Subject: [PATCH] Adding silent flag for hooks: --no-hooks. Close #387 --- README.md | 6 ++++++ lib/cmd-anonymizer.js | 7 ++++--- lib/cmds/help.js | 2 +- lib/hooks.js | 3 ++- 4 files changed, 13 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 749d7fa7..f450d948 100644 --- a/README.md +++ b/README.md @@ -66,6 +66,12 @@ gh help --all gh help ``` +### Global flags +Option | Usage | Type +--- | --- | --- +`--verbose` | *Optional* | `Boolean` +`--no-hooks` | *Optional* | `Boolean` + ## Pull requests ``` diff --git a/lib/cmd-anonymizer.js b/lib/cmd-anonymizer.js index 831efa40..bd2af5f9 100644 --- a/lib/cmd-anonymizer.js +++ b/lib/cmd-anonymizer.js @@ -41,11 +41,12 @@ CmdAnonymizer.prototype.isValueInOptions = function(options, value) { }; CmdAnonymizer.prototype.classify = function(word) { - var arg = this.extractArgument(word); + var arg = this.extractArgument(word), + whitelist = ['verbose', 'no-hooks']; - if (arg === 'verbose') { + if (whitelist.indexOf(arg) === 0) { this.invoked.push(word); - this.last = 'verbose'; + this.last = arg; return; } diff --git a/lib/cmds/help.js b/lib/cmds/help.js index 8ed5975e..8b75ae3c 100644 --- a/lib/cmds/help.js +++ b/lib/cmds/help.js @@ -148,7 +148,7 @@ Help.prototype.listFlags_ = function(command) { }; Help.prototype.listCommands_ = function(commands) { - var content = 'usage: gh [payload] [--flags]\n\n', + var content = 'usage: gh [payload] [--flags] [--verbose] [--no-hooks]\n\n', pos, command; diff --git a/lib/hooks.js b/lib/hooks.js index 90ee3ab3..3bfa3606 100644 --- a/lib/hooks.js +++ b/lib/hooks.js @@ -73,9 +73,10 @@ exports.invoke = function(path, scope, opt_callback) { before = exports.getHooksFromPath(path + '.before'), beforeOperations, afterOperations, + options = scope.options, context; - if (process.env.NODEGH_HOOK_IS_LOCKED) { + if (options.hooks === false || process.env.NODEGH_HOOK_IS_LOCKED) { opt_callback && opt_callback(); return; }