0

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?

Avery
  • 2,270
  • 4
  • 33
  • 35
  • Possible duplicate of [How can I run multiple npm scripts in parallel?](https://stackoverflow.com/questions/30950032/how-can-i-run-multiple-npm-scripts-in-parallel) – Avery Jul 12 '18 at 13:14

1 Answers1

1

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\""
psiphi75
  • 1,985
  • 1
  • 24
  • 36