git

githooks

Custom Git Hooks With NodeJs

Showing:

Popularity

Downloads/wk

208

GitHub Stars

5

Maintenance

Last Commit

7yrs ago

Contributors

0

Package

Dependencies

2

Size (min+gzip)

4.3KB

License

MIT

Type Definitions

Tree-Shakeable

No?

Categories

Readme

githooks

githooks is a tool help you build custom hooks of git easier.

Note

It was wrote by Node.js, so you should install nodejs at first.


Table of contents

Quick start

More

Quick start

Installation

npm install githooks -g

The command is "git-hooks", so you can call "git hooks" to run.

Usage

  Usage: git-hooks <cmd> [hook]

  Commands:

    configure [options]    configure your workspace
    install <hook>         install a hook
    autoinstall            auto install hooks based on your ".githooks" config
    remove <hook>          remove a hook
    clean                  clean all hooks
    list                   list all hooks
    *                     

  Options:

    -h, --help              output usage information
    -V, --version           output the version number
    -w, --workspace <path>  set the boot directory of the workspace. defaults to the current
    -c, --config <path>     specify a .githooks
    -f, --force             force to do

  Usage Examples:

    Install a "pre-commit" hook:
    $ git-hooks install pre-commit

    Remove a "pre-commit" hook:
    $ git-hooks remove pre-commit

    Remove all hooks:
    $ git-hooks clean

    List all hooks:
    $ git-hooks list

  Note:

    set a ".githooks" into your workspace, or use -c to specify one before installing githooks!

Example

get into your workspace

cd /your/workspace/

init a new empty .githooks file

git hooks configure –i

modify .githooks file

vi .githooks
module.exports = function(githooks) {
    githooks
        .hook('pre-commit')
        .rule({
            'index': 'index.html'
        })
        .on('match:index', function(files) {
            console.log(files); // output ['index.html'] while "index.html" is committing
        });
};

test your .githooks file

git hooks configure –t

install your hooks into git

git hooks autoinstall

More

License

MIT

Rate & Review

Great Documentation0
Easy to Use0
Performant0
Highly Customizable0
Bleeding Edge0
Responsive Maintainers0
Poor Documentation0
Hard to Use0
Slow0
Buggy0
Abandoned0
Unwelcoming Community0
100
No reviews found
Be the first to rate

Alternatives

No alternatives found

Tutorials

No tutorials found
Add a tutorial