Hello! I’m a little stumped on figuring out how one would “pass an arbitrary number of additional parameters from process.argv to the spawned process (e.g., node –harmony watcher-hw.js ls -l -h)” I guess because the (e.g.) only mentions one file. Putting this into the original watcher-spawn.js returns Error: watch ls is ENOENT. Forgive me I’m really new, and I’m sure the answer is much more obvious than I think it is.
Thanks for taking the time to post! I admit that question is pretty cryptic.
All I meant was that I wanted you to think about how you’d deal with an
argv that had an unpredictable number of elements.
const original = ['a', 'b', 'c']; const part = original.slice(1); // Contains ['b', 'c'], original is unchanged.
Considering the interplay between the Node.js program’s
argv array, and the arguments you pass to
spawn(), you could forward an arbitrary number of command line arguments like this:
const child = spawn(progess.argv, process.argv.slice(3));