Description
This is more of a question than a bug report, but can be actionable depending on discussion.
The README provides instructions on how to setup commitlint with husky. I'm curious if passing in $1
is actually necessary here:
npx husky add .husky/commit-msg 'npx --no -- commitlint --edit "$1"'
Upon testing, $1
always seems to evaluate to .git/COMMIT_EDITMSG
(which is also the default value for commitlint -e
). Although I have read sources that say $1
evaluates to the commit message itself (rather than a file path containing it), I have not found that to be the case, which I confirmed with the Git hooks docs:
It takes a single parameter, the name of the file that holds the proposed commit log message.
Is there an edge case where $1
evaluates to a different path that this is trying to handle? Or can it be safely omitted?
Also, I don't think this recommended command will work in Bash because string interpolation isn't supported in single-quotes:
npx husky add .husky/commit-msg \"npx --no -- commitlint --edit '$1'\"
I'm wondering if this appears to work because it silently falls back to using .git/COMMIT_EDITMSG
.
I made a test with the following commit hook to confirm:
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"
echo "$1"
echo '$1'
echo $1
Result:
$ git commit -am test
.git/COMMIT_EDITMSG
$1
.git/COMMIT_EDITMSG
Is this for a specific non-Bash environment?