How can I ensure that an NPM script runs only when a JS file is staged, specifically after a pre-commit
git hook (using Husky)? The scripts in my package.json
are as follows:
"scripts": {
...
"test": "jest",
"precommit": "npm test",
...
},
I'm looking to run the jest
script only if there are JS files staged. What's the best way to achieve this?