2

I just started to use a pre-commit hook in a project, in that script I run some grunt tasks like jshint and jsbeautifier.

The thing is that jsbeautifier does modify the files, so when it does, I have to restage the modified files.

Would it be possible to only have to stage those files only once?

BJ Myers
  • 6,617
  • 6
  • 34
  • 50
leseulsteve
  • 335
  • 3
  • 14

1 Answers1

0

As commented, nothing prevents your script to add the modified files.

You can also add by type of files:

git ls-files [path] | grep '\.js$' | xargs git add

A pre-commit hook like jish/pre-commit (presented here) includes a staging step (in lib/pre-commit/utils/staged_files.rb).

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250