Git Product home page Git Product logo

git-hooks-js's Introduction

git-hooks-js

NPM version Build Status Coverage Status Dependency Status npm

git-hooks 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:

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

Supported platforms

  • Unix
  • macOS

Install

Install git-hooks in your project.

npm install git-hooks --save-dev

To keep things organized, git-hooks 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

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.

Related projects

git-hooks-js's People

Contributors

tarmolov avatar cinderblock avatar rjmunro avatar getsnoopy avatar shdwjk avatar maxlath avatar ruslan-polutsygan avatar

Watchers

James Cloos avatar Shubham Mathur avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.