Reputation: 21
I'm trying to pass a program output as input to another program, but I don't know how to make it wait until the first one is finished.
npm run test | ./script.js
I'm trying to run that, but when I run it, tests are starting and the script is throwing an error immediately
Upvotes: 2
Views: 1721
Reputation: 189
the pipe gets the standard output directly to standard input, you can use an subshell to execute first then get the standard output into the standard input.
./script.js <<< "$(npm run test)"
other way to do this is to store the output into an temp_file then use this file as input of the script
nmp run test >> temp_file ; ./script.js < temp_file
Upvotes: 2