pre-commit is a pre-commit hook installer for git
. It will ensure that
your npm test
(or other specified scripts) passes before you can commit your
changes. This all conveniently configured in your package.json
.
But don't worry, you can still force a commit by telling git
to skip the
pre-commit
hooks by simply committing using --no-verify
.
It's advised to install the pre-commit module as a devDependencies
in your
package.json
as you only need this for development purposes. To install the
module simply run:
npm install --save-dev @xunlei/pre-commit
To install it as devDependency
. When this module is installed it will override
the existing pre-commit
file in your .git/hooks
folder. Existing
pre-commit
hooks will be backed up as pre-commit.old
in the same repository.
pre-commit
will try to run your npm run pre-commit
command in the root of the pakeage.json
path by default.
The only thing you need to do is add a pre-commit
script to your package.json
that specifies which scripts you want to have ran and in which order:
{
"name": "437464d0899504fb6b7b",
"version": "0.0.0",
"description": "ERROR: No README.md file found!",
"main": "index.js",
"scripts": {
"test": "echo \"Error: I SHOULD FAIL LOLOLOLOLOL \" && exit 1",
"pre-commit": "npm run test"
}
}
To learn
more about the scripts, please read the official npm
documentation:
https://npmjs.org/doc/scripts.html
And to learn more about git hooks read:
MIT