New:Introducing Socket Scanning for VS Code Marketplace Extensions.Learn more →
Get Started

git-hooks-plus

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

git-hooks-plus

A tool to manage project Git hooks

latest
Source
npmnpm
Version
1.0.1
Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

git-hooks-plus

NPM version Build Status Coverage Status Dependency Status npm

git-hooks-plus is forked from git-hooks-js and supports Windows.

git-hooks-plus is an utility for managing and running project git hooks for nodejs projects.

It has zero dependecies and easy to use.

Just install git-hooks and it will run your hooks when a hook is called by git.

Why do you need git hooks in your project?

Hooks are little scripts you can place in $GIT_DIR/hooks directory to trigger action at certain points.

They are very powerful and helpful.

You can do a lot of things with them:

  • Validate code and run tests before commit.
  • Check codestyle.
  • Spell check the commit message or check it format.
  • and etc.

Note. When you use git-hooks-plus, you should not modify $GIT_DIR/hooks directory manually because git-hooks-plus will do it for you.

Supported platforms

  • Unix
  • macOS
  • Windows

Install

Install git-hooks-plus in your project.

npm install git-hooks-plus --save-dev

To keep things organized, git-hooks-plus looks for scripts in sub-directories named after the git hook name. All these sub-directories should be stored in .githooks directory in the project root.

Let's create some dummy pre-commit hook.

mkdir -p .githooks/pre-commit
echo -e '#!/usr/bin/env node' "\nconsole.log('hi!');" > .githooks/pre-commit/hello.js
chmod +x .githooks/pre-commit/hello.js  # This may not working in Windows, but don't worry, hello.js will be executed through node

Then just try to commit and see how things are rolling.

git add .githooks package.json
git commit -m "Add git-hooks"

See also hooks examples.

It's worth to mention that our library checks for gitignore rules while executing scripts in .githooks/ directories.

Keywords

git

FAQs

Package last updated on 10 Nov 2017

Related posts