12

I'm setting up a node project with husky and I want to have a git-hook script run manually, without having to trigger it in git.

Example:

My package.json has the following:

{
...
    "scripts": {
        "precommit": // something goes here
    }
...
    "husky": {
        "hooks": {
            "pre-commit": "lint-staged"
        }
    },
...
}

If I run npm run precommit, the lint-staged hook step runs, WITHOUT the commit actually occurring in git.

Is this possible?

n8jadams
  • 991
  • 1
  • 9
  • 21

1 Answers1

12

It should be possible, since this answer illustrates you can simply call the .git/hooks/pre-commit

So as long as you are calling the hook directly, with its full path, you would run whatever it contains.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250