You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Terminal is Windows Command Prompt, using Git for Windows
Using husky 9.0.2
When running husky install with v8, the .git/config file was correctly modified with:
hooksPath = .husky
When running husky with v9, the .git/config is being modified - on Windows - with:
hooksPath = .husky\\_
(Note the escaped backslash.)
The result is that none of the hooks actually run. It looks like this path should be .husky/_ instead, even on Windows, because Git, when processing these paths, uses Linux forward-slash separators.
Demo / repro
With a brand new repository, installing husky 9 and running husky init gives me a demonstration pre-commit hook containing npm test:
C:\Dev>mkdir huskyplay
C:\Dev>cd huskyplay
C:\Dev\huskyplay>git init
Initialized empty Git repository in C:/Dev/huskyplay/.git/
C:\Dev\huskyplay>npm init
This utility will walk you through creating a package.json file.
...<npm init output elided>...
C:\Dev\huskyplay>npm i -D husky
added 1 package, and audited 2 packages in 1s
1 package is looking for funding
run `npm fund` for details
found 0 vulnerabilities
C:\Dev\huskyplay>npx husky init
C:\Dev\huskyplay>git add package.json
warning: in the working copy of 'package.json', LF will be replaced by CRLF the next time Git touches it
C:\Dev\huskyplay>git commit -m "A commit"
[master (root-commit) 1c74e28] A commit
1 file changed, 15 insertions(+)
create mode 100644 package.json
That should have failed, because husky init installs a demonstration pre-commit hook that calls npm test, and by default npm test fails because of the default value of "test": "echo \"Error: no test specified\" && exit 1",.
This shows that the hooks aren't running.
If I modify .git/config to read hooksPath = husky/_ instead of hooksPath = husky\\_, and then try again:
C:\Dev\huskyplay>git add package-lock.json
warning: in the working copy of 'package-lock.json', LF will be replaced by CRLF the next time Git touches it
C:\Dev\huskyplay>git commit -m "Another commit"
> huskyplay@1.0.0 test
> echo "Error: no test specified" && exit 1
"Error: no test specified"
husky - pre-commit script failed (code 1)
This time we see the expected hook fail.
The text was updated successfully, but these errors were encountered:
Context
When running
husky install
with v8, the .git/config file was correctly modified with:When running
husky
with v9, the .git/config is being modified - on Windows - with:(Note the escaped backslash.)
The result is that none of the hooks actually run. It looks like this path should be
.husky/_
instead, even on Windows, because Git, when processing these paths, uses Linux forward-slash separators.Demo / repro
With a brand new repository, installing husky 9 and running
husky init
gives me a demonstrationpre-commit
hook containingnpm test
:That should have failed, because
husky init
installs a demonstration pre-commit hook that callsnpm test
, and by defaultnpm test
fails because of the default value of"test": "echo \"Error: no test specified\" && exit 1",
.This shows that the hooks aren't running.
If I modify
.git/config
to readhooksPath = husky/_
instead ofhooksPath = husky\\_
, and then try again:This time we see the expected hook fail.
The text was updated successfully, but these errors were encountered: