I've got a problem with my pre-commit script. I'm trying to run "ng lint" of my angular project pre-commit file; I see the errors on logs when detects lint errors but the pre-commit processs pass sucessfully. I need to do ng-lint in pre-commit file because I'm going to run other validations... How can I get the message when the ng lint dont pass sucessfully?
My script:
#!/bin/bash
### other scripts to validate custom commits
-----------
### Run ng lint
echo "pre-commit hook --> linting" ng lint
ng lint
echo -e "ng lint pass sucessfully \n\n"
Log
pre-commit hook --> linting
Linting "front-firefly-backoffice"...
/home/apanez/Escritorio/htdocs/eci/front-firefly/src/app/stock/limit-sale/components/limit-sale-detail/limit-sale-detail.component.ts:30:14
ERROR: 30:14 component-class-suffix The name of the class LimitSaleDetailComp should end with the suffix Component (https://angular.io/styleguide#style-02-03)
Lint errors found in the listed files.
ng lint pass sucessfully
ng lintoutput withLINTMSG="$(ng lint)". Theng lintwill probably return 0 for successful completion and anything else when failing. You can then test that withif [ $? != 0 ]; then { processing error from $LINTMSG }.$?is set with the exit code of the last executed command. Most of commands (built-in or not) will return 0 for success and anything else for failure. I'll suggest you to read bash man page, section Special parameters.set -ein your shell script will make erroring subcommands an error