Piero
Piero

Reputation: 9273

Use NodeJS spawn to call node script with arguments

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

Upvotes: 1

Views: 3402

Answers (1)

Piero
Piero

Reputation: 9273

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

Upvotes: 2

Related Questions