0.0.1 • Published 9 years ago

hook-script-runner v0.0.1

Weekly downloads
1
License
MIT
Repository
github
Last release
9 years ago

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

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:

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
  2. Reset your local Git directory:

    rm .git/hooks # Delete the symlink
    mv .git/hooks.save .git/hooks # Restore the original hooks directory
  3. Clean up your package.json file if you added anything.

License

MIT