1

I'm trying to call a node js script with spawn, but this script accept arguments and I can't figure out how achieve this:

var build = spawn('node',['src/server/single.js build=complete incrementVersion=true uploadBuild=true')

I know that I can use exec instead of spawn, but I want live output that exec haven't. How can I do it?

EDIT: My problem isn't about pass arguments to a node js script, because I already do it, my problem is to pass argument to node js script using spawn

Piero
  • 9,173
  • 18
  • 90
  • 160
  • Possible duplicate of [How do I pass command line arguments to a nodejs program?](https://stackoverflow.com/questions/4351521/how-do-i-pass-command-line-arguments-to-a-nodejs-program) – Krease Apr 23 '18 at 20:13
  • Read https://medium.freecodecamp.org/node-js-child-processes-everything-you-need-to-know-e69498fe970a – Saeed Apr 24 '18 at 05:20

1 Answers1

1

I think the solution is this:

var child = spawn('node', ['src/server/single.js','app='+name,'build=complete', 'incrementVersion=true', 'uploadBuild=true']);

first argument is the command, second argument is an array with all arguments of the command

Piero
  • 9,173
  • 18
  • 90
  • 160