Skip to content

Commit

Permalink
fix(enabled): missing enabled option means hooks run, close #97
Browse files Browse the repository at this point in the history
  • Loading branch information
bahmutov committed Nov 18, 2016
1 parent e9cbc61 commit 4fd5796
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,9 @@ false
}
```

If the 'config.pre-git' object has the option 'enabled' missing, it is
assumed to be "true" and the hooks are executed.

You can always skip pre-commit hook (but not pre-push hook!) by using `-n` option

git commit -m "done, don't check me" -n
Expand Down
10 changes: 9 additions & 1 deletion src/pre-git.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,12 +143,20 @@ function getConfig() {
return pkg.config && pkg.config[packageName];
}

function hasEnabledOption(config) {
return 'enabled' in config;
}

function getTasks(label) {
var pkg = getPackage();
la(check.object(pkg), 'missing package', pkg);

const config = getConfig();
if (!config.enabled) {
if (!config) {
return;
}

if (hasEnabledOption(config) && !config.enabled) {
return;
}

Expand Down

0 comments on commit 4fd5796

Please sign in to comment.