0

Hey i want to add a script to my package.json but don't want to check in this addition to our git because it affects the behaviour of the project for my colleagues.

The script i want to add is a precommit-Hook which is handled by husky. Is there a possibility to have something like a package.override.json where i define the script and ignore the file in .gitignore or are there different approaches?

takethefake
  • 795
  • 1
  • 9
  • 20

1 Answers1

1

I can think of two solutions without using husky:

You can set up your own git hooks directly in the .git/hooks folder of your local repository. See https://git-scm.com/book/gr/v2/Customizing-Git-Git-Hooks for information on how to do that.

If that doesn't work out you and you're running a *nix OS, can always write your own commit alias using bash. Add something like

alias commit="npm run test && git commit"

to your ~/.bashrc file.

(Of course, the ideal is to convince your colleagues of the value husky provides.)

rouan
  • 5,339
  • 6
  • 22
  • 36