Skip to content

mmwtsn/hook-script-runner

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

90 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

hook-script-runner

wercker status

Install once, run everywhere.

Quick start

Install the Hook Script Runner module in an existing project:

$ npm install --save-dev hook-script-runner

Add some commands to your package.json file:

{
  "hooks": {
    "commit-msg": "echo 'What would Tim Pope do?'",
    "pre-commit": [
      "npm test -s",
      "npm run lint -s"
    ]
  }
}

These can be anything you want so long as it's executable inside your curent environment. Each hook name will accept either a string or an array of strings. If multiple commands are provided they will be run in order.

You can test your setup by either triggering a Git event (e.g. authoring a commit in the above example) or simply by running them as they're just executables after all:

$ ./.git/hooks/commit-msg
What would Tim Pope do?

Good question.

Disabling hooks

The following hooks can be disabled by passing the --no-verify option to git commit:

  • commit-msg
  • pre-commit

Uninstalling

During the installation process your project's local .git/hooks/ directory is backed up to .git/hooks.save/ and symlinked to a directory provided by this module.

To uninstall:

  1. Remove the module:
rm -rf node_modules/hook-script-runner
  1. Reset your local Git directory:
rm .git/hooks # Delete the symlink
mv .git/hooks.save .git/hooks # Restore the original hooks directory
  1. Clean up your package.json file if you added anything.

Additional resources

For a list of all available hooks and a detailed description of each see Git's documentation online or off: man githooks.

For a more in-depth look at the hook system, check out these articles:

Local development

To get started you'll need at least Node.js v0.12.x.

There's an outstanding issue with npm calling the "preinstall" script on npm install. You'll want to bypass scripts on install:

$ npm install --ignore-scripts

License

MIT

About

Automatically run your Git hook scripts with npm

Resources

License

Stars

Watchers

Forks

Packages

No packages published