Answer the question
In order to leave comments, you need to log in
How to run git pre-push via husky conditionally?
There is a project consisting of several folders. Husky is configured to run tests in one of them:
{
"scripts": {
"test:coverage": "jest ./client/public/app-react/src --coverage",
},
"husky": {
"hooks": {
"pre-push": "npm run test:coverage"
}
}
}
Answer the question
In order to leave comments, you need to log in
Husky can't be configured this way, but you can "configure" the command he runs to check for changes. The most popular way today is probably the use of lint-staged .
// package.json
{
"husky": {
"hooks": {
"pre-push": "lint-staged"
}
}
}
// lint-staged.config.js
module.exports = {
'./client/public/app-react/src/**/*.js': () => 'jest ./client/public/app-react/src --coverage',
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question