4 * Script that will execute the downloaded phantomjs binary. stdio are
5 * forwarded to and from the child process.
7 * The following is for an ugly hack to avoid a problem where the installer
8 * finds the bin script npm creates during global installation.
10 * {NPM_INSTALL_MARKER}
13 var path = require('path')
14 var spawn = require('child_process').spawn
16 var binPath = require(path.join(__dirname, '..', 'lib', 'phantomjs')).path
18 var args = process.argv.slice(2)
20 // For Node 0.6 compatibility, pipe the streams manually, instead of using
21 // `{ stdio: 'inherit' }`.
22 var cp = spawn(binPath, args)
23 cp.stdout.pipe(process.stdout)
24 cp.stderr.pipe(process.stderr)
25 process.stdin.pipe(cp.stdin)
27 cp.on('error', function (err) {
28 console.error('Error executing phantom at', binPath)
29 console.error(err.stack)
32 cp.on('exit', function(code){
33 // Wait few ms for error to be printed.
34 setTimeout(function(){
39 process.on('SIGTERM', function() {