Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Run multiple processes (multiple watch commands)

Tags:

makefile

I'm trying to make a Makefile that executes multiple commands. Example:

script:
  cat scripts/*.js > public/scripts/scripts.js

vendor:
  cat vendor/*.js > public/scripts/vendor.js

watchStyles:
  stylus -w -u nib styles/styles.styl -o public/styles

watchScripts:
  watchr -e "watch('scripts/.*\.js') {system 'make scripts'}"

watchVendor:
  watchr -e "watch('vendor/.*\.js') {system 'make vendor'}"

Right now I have to open up 3 terminals, which is annoying. How can I run only one via make watch?

watch: watchStyles watchScripts watchVendor
like image 482
Jonathan Ong Avatar asked Feb 20 '23 10:02

Jonathan Ong


1 Answers

If you are using GNU make then -j option allows it to build targets in parallel, e.g.:

make -j4 watchStyles watchScripts watchVendor
like image 184
Maxim Egorushkin Avatar answered Mar 05 '23 19:03

Maxim Egorushkin