Peter
Peter

Reputation: 2394

NPM and How to run all sequential commands even if one command fails

I have an npm script where one of the commands, in this case, the test script, can fail.

"test": "npm run init && npm run test && npm run end"

If the test script fails the end script is never executed.
Is there a way to force the execution of the end script even if test fails? Thanks!

Upvotes: 2

Views: 2888

Answers (1)

alexmac
alexmac

Reputation: 19597

Use ; control operator:

npm run init ; npm run test ; npm run end

; means execute the preceding statement and, after it completes, proceed to the next statement.

Upvotes: 6

Related Questions