Reputation: 247
As we know phantomjs 2 isn't officially released, is it possible to download an .exe and use childProcess.spawn('./phantomjs midges.js)
to run phantomjs2, it runs via exec but doesn't when I use spawn. I'm trying to avoid using exec since the phantomjs process returns lot of data back and it's a bad practice to use exec in this case and also that I can't run multiple exec's of phantoms
Upvotes: 1
Views: 56
Reputation: 16838
Yes, it's possible. Here's a minimal example, adapted from node's docs.
var spawn = require('child_process').spawn,
child = spawn('./phantomjs', ['midges.js']);
child.stdout.on('data', function (data) {
console.log('stdout: ' + data);
});
child.stderr.on('data', function (data) {
console.log('stderr: ' + data);
});
child.on('close', function (code) {
console.log('child process exited with code ' + code);
});
Upvotes: 2