1

I have this command in my package.jason:

"chrome": "node --max_old_space_size=10000 build/dev-server.js --arg testus | node --harmony test/e2e/puppeteer/index.js",

I want to build my app before using my automated testing tool.

But right now both commands start at the same time.

How to do the second one waits the first one to be finished?

alex
  • 7,111
  • 15
  • 50
  • 77
  • Possible duplicate of [Running NPM scripts sequentially](https://stackoverflow.com/questions/39172536/running-npm-scripts-sequentially) – Sergey Lapin Sep 06 '17 at 06:36

2 Answers2

1

To run something in sequence in linux command line you use &&

"chrome": "node --max_old_space_size=10000 build/dev-server.js --arg testus && node --harmony test/e2e/puppeteer/index.js",
Alexandru Olaru
  • 6,842
  • 6
  • 27
  • 53
  • Oh, it almost worked. But now the server is listening to port 8080 and it's stuck there without running the command after `&&` ... – alex Sep 06 '17 at 06:38
  • An other way to do it is to put the server in background with `&` and then run the second after `;` Sort of `first_command & ; second_command` The `;` same as `&&` for sequence – Alexandru Olaru Sep 06 '17 at 06:52
1

what about a proper bash script like:

node --max_old_space_size=10000 build/dev-server.js --arg testus 
while [ ! $(http://example.org 2>/dev/null | head -n 1 | cut -d$' ' -f2) -eq 200 ]; do
  echo "Waiting for server to start!"
  sleep 2
done
echo "Server started !!!! "
node --harmony test/e2e/puppeteer/index.js"
Théophile Pace
  • 826
  • 5
  • 14