Run npm scripts in series

Elijah Manor
InstructorElijah Manor

Share this video with your friends

Send Tweet
Published 6 years ago
Updated 4 years ago

After creating several npm script it becomes useful to run multiple scripts back-to-back in series. This is a nice feature because you can enforce that one script needs to complete before starting another one.

[00:01] Before we run our tests, it would be nice to lint our JavaScript and our styles first. What we're going to do is we're going to npm run eslint and then we're going to use the double ampersand in order to run multiple scripts in series. Then we'll also run our style lint script to lint our SaaS. The nice thing about this is that if any of the linting fails, then the rest of the command is aborted.

[00:24] Let's quit to our terminal and run npm test or npmt, and you'll see first it's linting our JavaScript and linting our SaaS, then running our tests. In this case, all the linting passed, so the tests will run at the end. This time, let's go into our index CSS file and change one of our colors to green, then we'll save that.

[00:46] We'll run our tests, but this time, the JavaScript linting passed, but our style lint failed, because we're using a named color and that's one of our rules, so we'll need to address that linting error, if we want the test to run.