Security update to Drupal 8.4.6
[yaffs-website] / node_modules / phantomjs-prebuilt / bin / phantomjs
1 #!/usr/bin/env node
2
3 /**
4  * Script that will execute the downloaded phantomjs binary.  stdio are
5  * forwarded to and from the child process.
6  *
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.
9  *
10  * {NPM_INSTALL_MARKER}
11  */
12
13 var path = require('path')
14 var spawn = require('child_process').spawn
15
16 var binPath = require(path.join(__dirname, '..', 'lib', 'phantomjs')).path
17
18 var args = process.argv.slice(2)
19
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)
26
27 cp.on('error', function (err) {
28   console.error('Error executing phantom at', binPath)
29   console.error(err.stack)
30 })
31
32 cp.on('exit', function(code){
33   // Wait few ms for error to be printed.
34   setTimeout(function(){
35     process.exit(code)
36   }, 20)
37 });
38
39 process.on('SIGTERM', function() {
40   cp.kill('SIGTERM')
41   process.exit(1)
42 })