How to run several commands on precommit with husky npm module?

Rantiev picture Rantiev · Apr 22, 2017 · Viewed 7.3k times · Source

I use husky to check JS before commit. In my package.json i have

"scripts": {
    "lintStyles": "stylelint app/**/*.scss",
    "fixStylesLinting": "stylelint app/**/*.scss --fix",
    "lintJS": "eslint app/**/*.js",
    "fixJSLinting": "eslint --fix app/**/*.js",
    "precommit": "npm run lintJS"
  }

It works, what i don't understand is how can i run both lintJS, lintStyles commands.

Answer

chris_r picture chris_r · Jul 14, 2017

to include more than one script add &&for ex:

precommit: npm run lint:sass && npm run lint:js