I have a bash script that runs test for all workspaces in npm. Here is the bash script:
npm ci --no-optional;
set -eE;
npm run test; #test script in root package.json of workspace
Now in root package.json scripts, test runs test on all workspaces like this:
"test": "npm run test -ws --if-present
Problem: I have workspace A, B, C and D. when the bash script runs and there is a failure or error when running test on workspace A, it continues on to running tests for B,C and D.
Solution asked for: Stop executing as soon as there is a failure in workspace A and exit.
Things I have tried: using trap to listen to ERR or EXIT and calling EXIT 1 within trap. It does not work.