0

I'm wondering if a failed npm cmd will cause my shell script to not execute my next command.

For example here is what I'm trying to do

npm run some_test_script
pkill something

What's happening is that my npm run some_test_script is failing but one thing I noticed is that the next cmd pkill something is not getting executed.

However, when my npm run some_test_script doesn't error out the next pkill something runs as intended. Is this an expected behavior? If so, is there a way I can still execute my pkill something regardless of whether or not npm run some_test_script works or not?

I want the pkill something to run after npm run some_test_script works/doesn't work so I don't want to use a & here

Thanks for your help!

Tim
  • 2,221
  • 6
  • 22
  • 43
  • Your shell script should do exactly that, i.e. _"`pkill something` [should] run after `npm run some_test_script` works/doesn't work "_. It's essentially the same as this oneliner; `npm run some_test_script; pkill something`. You say _"...the next cmd `pkill something` is not getting executed"_, so "yes" it's unexpected behavior, (unless [`set -e`](https://www.gnu.org/software/bash/manual/html_node/The-Set-Builtin.html) has been specified). What [shebang](https://stackoverflow.com/questions/10376206/what-is-the-preferred-bash-shebang) do you specify, presumably `#!/usr/bin/env bash` or other? – RobC Jul 09 '20 at 08:03
  • @RobC To be specific my script is doing this: npm install, start python app, npm run test_coverage, pkill -f my_py_app When test_coverage fails the next set of cmds pkill -f my_py_app doens't seem to be executing but when it does succeed i see that my_py_app is successfully being killed – Tim Jul 09 '20 at 19:30
  • It's probably best to update your question with further details regarding what you're actually doing then. The details currently provided in your OP are perhaps too fictitious/contrived for the community to be able to provide a suitable answer. Given the example that you've show in your OP it''s unexpected behavior. – RobC Jul 10 '20 at 09:21

0 Answers0