Our product documentation tells our developers to run git config commmit.template .gitmessage
. However, many developers have not done so and are not following our commit template.
I'm using the following husky hook to stop a commit if they haven't set commit.template
.
"husky": {
"hooks": {
"pre-commit": "if `git config commit.template` | grep -q '.gitmessage'; then lint-staged; else echo 'Commit template not being used. Please run git config commit.template .gitmessage' && exit -1; fi"
}
},
However, I get the following error when running it on Windows.
> if `git config commit.template` | grep -q '.gitmessage'; then lint-staged; else echo 'Commit template not being used. Please run git config commit.template .gitmessage' && exit -1; fi
config was unexpected at this time.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! gittest@1.0.0 gitcommit: `if `git config commit.template` | grep -q '.gitmessage'; then lint-st aged; else echo 'Commit template not being used. Please run git config commit.template .gitmessage' && e xit -1; fi`
Is there an approach I can take that works for both Windows and Unix?