npm-run-all
npm-run-all copied to clipboard
npm-run-all vs ampersand
I'm not sure if understand of difference between:
- npm-run-all script-one script-two and
- script-one & script-two
Can anybody explain? What is the difference? Why I should use npm-run-all?
Thank you for the question.
At first, npm-run-all script-one script-two and script-one & script-two is pretty different. The npm-run-all script-one script-two is equivalence to npm run script-one && npm run script-two. In short, npm-run-all is a tool to run multiple npm-scripts. In addition;
- You can use glob-like pattern matching. E.g.
npm-run-all build:**. This allow you to simplify npm-scripts. - You can run multiple npm-scripts in parallel on cross platform. E.g.
npm-run-all -p watch:js watch:css. This is almost equivalence tonpm run watch:js & npm run watch:css, but works on Windows which doesn't support the&operator, as well. - Maybe
--raceoption is useful for tests. E.g.npm-run-all -p -r test-server testruns the test server and test in parallel, then it will kill the test-server automatically after the test completed.
Documents is here: https://github.com/mysticatea/npm-run-all/blob/master/docs/npm-run-all.md