Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use a Windows compatible script in release note #1380

Closed
1 task done
fisker opened this issue Feb 3, 2024 · 2 comments
Closed
1 task done

Use a Windows compatible script in release note #1380

fisker opened this issue Feb 3, 2024 · 2 comments

Comments

@fisker
Copy link

fisker commented Feb 3, 2024

Troubleshoot

If you're migrating from husky 4, see:
https://typicode.github.io/husky/migrate-from-v4.html

Context
Please describe your issue and provide some context:

  • Terminal or GUI client (PowerShell, Git Bash, GitHub Desktop, ...)
  • If applicable, content of the failing hook
  • If possible, minimal steps to reproduce the issue

Thank you!

In v9 release note,

echo "npm test" > .husky/pre-commit

is suggested to use, but it should not work on cmd.exe, in my experience

node --eval "fs.writeFileSync('.husky/pre-commit','npm test\n')" 

should work for any shell, maybe worth to update?

Context: prettier/prettier#16000 (comment)

@typicode
Copy link
Owner

typicode commented Feb 4, 2024

Thanks for the feedback 🙂 you're right about it not working on Windows.

I've updated the changelog so that This can be accomplished using your favorite editor, a script or a basic echo command is closer to the v9 example. I've also added that it's for Linux/macOS.

The idea with v9 update is that you don't need a special command anymore. That's what I wanted to showcase with echo 'npm test' > .husky/pre-commit.

Previously, npx husky add .husky/pre-commit "npm test" was kind of necessary since hooks were more complex.

For reference,it was doing the following to the hook file:

  • adding shebang
  • adding code to source husky code
  • setting correct permission
  • ... and finally adding npm test

Now, just creating a file with the hook code is sufficient. Most users will probably use their code editor like they do for editing their other config files.

I feel that node --eval "fs.writeFileSync('.husky/pre-commit','npm test\n')" could confuse beginners that aren't familiar with fs API or they may end up relying on it to change hook.

@typicode
Copy link
Owner

typicode commented Feb 5, 2024

I just saw that it's consistent with the way prettier config is installed, you can forget about my last comment :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants