I have a server I want to run (on one HTTP port), and then another script (which runs (temporarily) on another port).
I'm using a pipe in order to let these run concurrently, and brackets to group the commands such that sleep occurs first (the second script accesses the server started in the first, so there needs to be some time for the first to be set up).
It works fine, with the server getting started and the sleep and test file executing correctly thereafter, but the terminal process does not exit automatically after the test as it does when just running the script.
npm run start-json-server | { sleep 1; node './test/index-cjs.js' ; }
What do I need to do to allow a natural exit (preferably without going through the trouble of finding the process and killing it)?
Update: I realized it was still running (duh) because the first script, as a server, doesn't terminate... But is there a way I can get it to terminate, again, preferably without finding its PID?
start-json-server
one--once the node test script is finished.