How to use the child_process.execFile function in child_process

To help you get started, we’ve selected a few child_process examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github chrisvfritz / prerender-spa-plugin / lib / compile-to-html.js View on Github external
function capturePage () {
            attemptsSoFar += 1

            ChildProcess.execFile(
              Phantom.path,
              phantomArguments,
              {maxBuffer: 1048576},
              function (error, stdout, stderr) {
                if (error || stderr) {
                  // Retry if we haven't reached the max number of capture attempts
                  if (attemptsSoFar <= maxAttempts) {
                    return capturePage()
                  } else {
                    if (error) throw error
                    if (stderr) throw stderr
                  }
                }
                callback(stdout)
                Server.stop()
              }
github semiromid / compress-images / test / node_modules / compress-images / index.js View on Github external
Sites:
        https://pngquant.org
        https://github.com/imagemin/pngquant-bin

        Example: 
        base:
        ['-o', output, input]
        */
        var array;
        if(false != enginepng.png.command){
          array = enginepng.png.command.concat(['-o', output, input]);  
        }else{
          array = ['-o', output, input];
        }

        execFile(pngquant, array, function (err) {

            if(option.statistic){
              //Block statistic
              //- - - - - - - - - - - - -  - - - - - - - - - - -
              //Узнаем размер файла после сжатия
              size_output = getFilesizeInBytes(output);
              
              //Находим на сколько процентов удалось сжать файл
              percent = size_output / size_in;
              percent = percent * 100;
              percent = 100 - percent;
              percent = Math.round(percent * 100) / 100;

              return callback(size_in, size_output, percent);  
              //- - - - - - - - - - - - -  - - - - - - - - - - -
            }
github nats-io / nats.ts / test / closequickly.js View on Github external
port: PORT
        });


        var timer;

        nc.flush(function() {
           nc.subscribe("started", function(m) {
               nc.publish("close");
           });
            timer = setTimeout(function() {
                done(new Error("process didn't exit quickly"));
            }, 10000);
        });

        var child = child_process.execFile('node', ['./test/support/exiting_client.js', PORT], function(error) {
            if(error) {
                nc.close();
                done(error);
            }
        });

        child.on('exit', function(code, signal) {
            if(timer) {
                clearTimeout(timer);
                timer = null;
            }
            nc.close();
            if(code !== 0) {
                done("Process didn't return a zero code: ", code, signal);
            } else {
                done();
github arshad / kaizoku / lib / kaizoku.js View on Github external
}
    } else {
      try {
        key = registry('HKLM/Software/VideoLAN/VLC')
      } catch (err) {
        try {
          key = registry('HKLM/Software/Wow6432Node/VideoLAN/VLC')
        } catch (e) {
        }
      }
    }
    if (key) {
      var vlcPath = key['InstallDir'].value + path.sep + 'vlc'
      VLC_ARGS = VLC_ARGS.split(' ');
      VLC_ARGS.unshift(localHref);
      var vlcProc = proc.execFile(vlcPath, VLC_ARGS);

      vlcProc.on('close', function (code) {
        engine.destroy(function () {
          process.exit(0);
        })
      });
    }
  }else{
    var root = '/Applications/VLC.app/Contents/MacOS/VLC'
    var home = (process.env.HOME || '') + root;
    var vlc = proc.exec('vlc ' + VLC_ARGS + ' ' + localHref + ' || ' + root + ' ' + VLC_ARGS + ' ' + localHref + ' || ' + home + ' ' + VLC_ARGS + ' ' + localHref, function (error, stdout, stderror) {
      if (error) {
        process.exit(0)
      }
    });
github mozilla / dxr / tooling / node / node_modules / lockdown / node_modules / npmconf / node_modules / uid-number / uid-number.js View on Github external
if (typeof cb !== "function") cb = uid, uid = null
  if (gid == null) gid = process.getgid()
  if (uid == null) uid = process.getuid()
  if (!isNaN(gid)) gid = gidCache[gid] = +gid
  if (!isNaN(uid)) uid = uidCache[uid] = +uid

  if (uidCache.hasOwnProperty(uid)) uid = uidCache[uid]
  if (gidCache.hasOwnProperty(gid)) gid = gidCache[gid]

  if (typeof gid === "number" && typeof uid === "number") {
    return process.nextTick(cb.bind(null, null, uid, gid))
  }

  var getter = require.resolve("./get-uid-gid.js")

  child_process.execFile( process.execPath
                        , [getter, uid, gid]
                        , function (code, out, err) {
    if (er) return cb(new Error("could not get uid/gid\n" + err))
    try {
      out = JSON.parse(out+"")
    } catch (ex) {
      return cb(ex)
    }

    if (out.error) {
      var er = new Error(out.error)
      er.errno = out.errno
      return cb(er)
    }

    if (isNaN(out.uid) || isNaN(out.gid)) return cb(new Error(
github facebookarchive / mention-bot / mention-bot.js View on Github external
return new Promise(function(resolve, reject) {
    var args = ['--silent', '-L', url];

    if (cookies) {
      args.push('-H', `Cookie: ${cookies}`);
    }

    require('child_process')
      .execFile('curl', args, {encoding: 'utf8', maxBuffer: 1000 * 1024 * 10}, function(error, stdout, stderr) {
        if (error) {
          reject(error);
        } else {
          resolve(stdout.toString());
        }
      });
  });
}
github jupyterlab / jupyterlab_app / src / main / server.ts View on Github external
this._startServer = new Promise((resolve, reject) => {
            let urlRegExp = /http:\/\/localhost:\d+\/\S*/g;
            let tokenRegExp = /token=\w+/g;
            let baseRegExp = /http:\/\/localhost:\d+\//g;
            let home = app.getPath('home');

            this._nbServer = execFile(this._info.environment.path, ['-m', 'jupyter', 'notebook', '--no-browser'], { cwd: home });

            this._nbServer.on('exit', () => {
                this._serverStartFailed();
                reject(new Error('Could not find Jupyter in PATH'));
            });

            this._nbServer.on('error', (err: Error) => {
                this._serverStartFailed();
                reject(new Error('Could not find Jupyter in PATH'));
            });

            this._nbServer.stderr.on('data', (serverBuff: string) => {
                let urlMatch = serverBuff.toString().match(urlRegExp);
                if (!urlMatch) {
                    return;
                }
github semiromid / compress-images / index.js View on Github external
http://advsys.net/ken/util/pngout.htm
        https://github.com/imagemin/pngout-bin
        
        Example: 
        base:
        ['input.png', 'output.png']
        ['input.png', 'output.png', '-s0', '-k0', '-f0']
        */
        var array;
        if(false != enginepng.png.command){
          array = [input, output].concat(enginepng.png.command);  
        }else{
          array = [input, output];
        }
        
        execFile(pngout, array, function (err) {
            if(err === null){           
                if(option.statistic){
                  //Block statistic
                  //- - - - - - - - - - - - -  - - - - - - - - - - -
                  //Узнаем размер файла после сжатия
                  size_output = getFilesizeInBytes(output);
                  
                  //Находим на сколько процентов удалось сжать файл
                  percent = size_output / size_in;
                  percent = percent * 100;
                  percent = 100 - percent;
                  percent = Math.round(percent * 100) / 100;

                  return callback(size_in, size_output, percent, null);  
                  //- - - - - - - - - - - - -  - - - - - - - - - - -
                }
github GoogleChrome / lighthouse / lighthouse-core / scripts / lantern / collect-traces.js View on Github external
await new Promise((resolve, reject) => {
    execFile('node', [
      path.join(LH_ROOT, 'lighthouse-cli'),
      url,
      `-G=${artifactsFolder}`,
    ], (_, stderr) => {
      if (stderr) reject(stderr);
      else resolve();
    });
  });
  const trace = fs.readFileSync(`${artifactsFolder}/defaultPass.trace.json`, 'utf-8');
github jclulow / smartos-isomerge / lib / u.js View on Github external
function fsck(device, callback)
{
  assert(device);
  log(' * #cyan[fsck] ' + device);
  var args = ['-y', device];
  execFile('/usr/sbin/fsck', args, function(err, stdout, stderr) {
    if (err) {
      log('    - #red[fsck stdout:] ' + stdout);
      log('    - #red[fsck stderr:] ' + stderr);
      return callback(err);
    }
    return callback();
  });
}

child_process

This package name is not currently in use, but was formerly occupied by another package. To avoid malicious use, npm is hanging on to the package name, but loosely, and we'll probably give it to you if you want it.

ISC
Latest version published 8 years ago

Package Health Score

65 / 100
Full package analysis