Anita Mehta
Anita Mehta

Reputation: 577

How to stop npm start , when lint or Unit testcase fails?

I am using npm start with lint and unit test case, if lint or test case fails, npm should not up the api, but I am not able to do.

Here is code I am using:

"scripts": {
    "start": "gulp lint & npm test & node src/server/index.js",
    "test": "mocha --timeout 10000"
  },

Please help me what I have to do for it, I searched on internet also, but not getting the proper solution.

Upvotes: 1

Views: 757

Answers (2)

Ilia Frenkel
Ilia Frenkel

Reputation: 1977

Use && instead of &:

"scripts": {
"start": "gulp lint && npm test && node src/server/index.js",
"test": "mocha --timeout 10000"

},

Upvotes: 2

Gustavo Toro
Gustavo Toro

Reputation: 450

You can simply rewrite the code like this:

"scripts": {
  "start": "gulp lint && npm test && node src/server/index.js",
  "test": "mocha --timeout 10000"
},

Double && will never start execution of node server if previous steps contains errors.

Upvotes: 2

Related Questions