Parse start scripts better, like npm does
We do a braindead parsing of package and/or bosco-service start scripts here: https://github.com/tes/bosco/blob/a7bc7c484face457de1b259d77f38b5d79a9b878/src/RunWrappers/Node.js#L84-L90
npm itself uses "sh -c" to run package scripts (non-windows): https://github.com/npm/npm/blob/master/lib/utils/lifecycle.js#L198-L207 so they have full shell parsing available to them, including, I believe, env variable definition, pipes, redirects and all sorts of other things (even subshells?).
We need to do better than we do, at least freaking out if we see pipes/redirects/env var definitions. They should be able to define a bosco-friendly start in their bosco-service.json, although I'm not 100% sure this is supported currently.
Unfortunately, https://github.com/substack/node-shell-quote which was the only obvious lib I found, has some rough edges. I don't really trust any implementations of this sort of stuff, there's too many gotchas.
What's the example?
The run wrappers are all about starting / stopping long running processes - in this instance node via pm2 - not executing arbitrary commands like exec does, so I'm unclear of why we want the start command to be something arbitrarily complex that pm2 probably couldn't process anyway?
I think I'm mostly worried about start scripts that define env vars like:
"start": "MY_VAR=foo NODE_SOMETHING=53 node --node_arg server.js extra args 'one more arg'",
And that quote args with spaces in them. I admit that this is mostly paranoia to make sure things work "as expected" down the road.
Ok - I like the 'be prepared' theme, but not sure even if we did solve the parsing that PM2 would know what to do with the above - it's pretty picky in what it will run.
We can pass in script, args, and nodeArgs, for sure with pm2.start(), and by looking at the code, we should be able to pass in env as well. We'd just have to parse it all out.