0.1.0 • Published 7 years ago

shared-node-git-hooks v0.1.0

Weekly downloads
4
License
MIT
Repository
github
Last release
7 years ago

shared-node-git-hooks

Install (Node.js >= 0.12.0)

$ npm install shared-node-git-hooks --save-dev

Usage

Add your scripts to ./hooks and name them as git hooks :

applypatch-msg
pre-applypatch
post-applypatch
pre-commit
prepare-commit-msg
commit-msg
post-commit
pre-rebase
post-checkout
post-merge
pre-push
pre-receive
update
post-receive
post-update
pre-auto-gc
post-rewrite

A generic script is symlinked in .git/hooks when you npm install your project. The script will look for an executable file with a ~matching name in your ./hooks and run it if found.

All of those scripts MUST be JS (node) scripts

Assumption

This project assumes that:

  • you have a package.json, .git/ and hooks/ in the root of your project.
  • you want to run your hooks with the same env $PATH you have when you run npm install (this will allow git GUI like Tower to access node through nvm for example)

Example

Save the following as ./hooks/pre-commit

#!/usr/bin/env node

console.log('refusing all commits!')
process.exit(1)

Remember to chmod +x ./hooks/pre-commit.

Related projects