2

I had tslint running in my pre commit hook for a while now without issue, and I just added stylelint as well. However I noticed that when I added stylelint tslint stopped working. After some digging around I found the order I declare them in the pre-commit file makes a difference.

For example if this is my pre-commit file then failures on ng lint will be ignored, but failures on npm run stylelint exit and block the commit.

#!/bin/sh
git pull origin
ng lint
npm run stylelint

Here I flip the order of ng lint and stylelint and I find the behavior is reversed, now failures on stylelint are ignored while failures on ng lint exit and block the commit.

#!/bin/sh
git pull origin
npm run stylelint
ng lint

How do I write this so that the commit will be blocked when anything in this returns an exit code?

efarley
  • 8,371
  • 12
  • 42
  • 65

1 Answers1

4

Check out this question, which ultimately is what yours boils down to.

Short answer: add set -e at the beginning of your script. It'll cause the whole thing to abort as soon as one fails.

jhpratt
  • 6,841
  • 16
  • 40
  • 50