Run multiple commands in node package file?

For instance:

"scripts": {
    "watch": "coffee --watch --compile .; compass watch public/compass"
}, 

How can I make this work, so it compiles my coffescripts files and my compass project?

+4
source share
2 answers

http://substack.net/task_automation_with_npm_run

sequential subtasks

If you have two tasks that you want to run sequentially, you can simply run npm for each task separated by & &:

"build": "npm run build-js && npm run build-css"

parallel subtasks

If you want to run several tasks in parallel, just use them as a separator!

"watch": "npm run watch-js & npm run watch-css"
+15
source

Install parallelshell npm pacakge

npm install parallelshell --save-dev

Use it instead &in your npm script (s)

"build": "echo TODO: build the project and start watching",
"serve": "echo TODO: start a development web server",
"start": "parallelshell \"npm start build\" \"npm start serve\""

(Mac, Linux, Windows)

$ npm start

--- ---

.js, Node.js child_process. :

"start": "node tools/start.js"

tools/start.js :

https://github.com/kriasoft/aspnet-starter-kit/blob/master/tools/start.js

+1

Source: https://habr.com/ru/post/1540814/


All Articles