Skip to content
This repository has been archived by the owner on Nov 4, 2022. It is now read-only.

Commit

Permalink
Adding silent flag for hooks: --no-hooks.
Browse files Browse the repository at this point in the history
Close #387
  • Loading branch information
henvic committed Jun 22, 2015
1 parent 686326d commit f201b31
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 5 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,12 @@ gh help --all
gh help <command>
```
### Global flags
Option | Usage | Type
--- | --- | ---
`--verbose` | *Optional* | `Boolean`
`--no-hooks` | *Optional* | `Boolean`
## Pull requests
```
Expand Down
7 changes: 4 additions & 3 deletions lib/cmd-anonymizer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
2 changes: 1 addition & 1 deletion lib/cmds/help.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ Help.prototype.listFlags_ = function(command) {
};

Help.prototype.listCommands_ = function(commands) {
var content = 'usage: gh <command> [payload] [--flags]\n\n',
var content = 'usage: gh <command> [payload] [--flags] [--verbose] [--no-hooks]\n\n',
pos,
command;

Expand Down
3 changes: 2 additions & 1 deletion lib/hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit f201b31

Please sign in to comment.