Reputation: 51
I have some start scripts that look like this:
"nodemonBabel": "nodemon src/index.js --exec babel-node",
"nodemonLint": "nodemon src/index.js --exec 'npm run lint && node'"
I use npm run nodemonBabel
in cli to watch my code with nodemon
and trigger Babel to transpile it on code change. I also use npm run nodemonLint
to watch with nodemon
while triggering eslint
on code change.
How do I combine both scripts into a single line? I.e, watch my code with nodemon, lint and transpile with Babel from a single script which I don't have to rerun for every change?
Upvotes: 0
Views: 821
Reputation: 2065
What you want to do is run two scripts concurrently, see here: How can I run multiple npm scripts in parallel?
Use a package called concurrently.
npm i concurrently --save-dev
Then setup your npm run dev
task as so:
"dev": "concurrently --kill-others \"npm run nodemonBabel\" \"npm run nodemonLint\""
Upvotes: 1