How to use the child_process.spawn 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 dudewheresmycode / GifTuna / app / main.js View on Github external
// var input = prefs.file.input;
  var w = prefs.dimensions.width || 320;
  var h = prefs.dimensions.height || 240;
  var fps = prefs.fps || 24;
  var stats = prefs.color.stats_mode || 'full';
  // var colors = prefs.color.colors || 256;
  var transparency = (prefs.color.alpha?1:0) || 0;
  var colors = prefs.color.count || 256;

  var scaleCmd = "scale="+w+":"+h;

  var vf = util.format("fps=%s,%s:flags=lanczos,palettegen=stats_mode=%s:max_colors=%s:reserve_transparent=%s", fps, scaleCmd, stats, colors, transparency);

  if(ffmpeg_ps) ffmpeg_ps.kill();

  ffmpeg_ps = spawn(ffmpeg_path, ["-i", input, "-vf", vf, "-f", "image2", "-vcodec", "png", "pipe:1"])
  var data = [];
  ffmpeg_ps.stdout.on('data',function(d){
    data.push(d);
  });
  ffmpeg_ps.stderr.on('data',function(d){
    // console.log("stderr",d.toString());
  });
  ffmpeg_ps.on('close',function(){
    event.sender.send('paletteResult', Buffer.concat(data).toString('base64'));
  });
})
ipcMain.on('cancelProcess', (event,opts) => {
github Ang-YC / wx-voice / index.js View on Github external
_decodeSilk(input, frequency, callback) {
        var output  = this._getTempFile(input + ".pcm"),
            decoder = spawn(this._getSilkSDK("decoder"), [input, output, "-Fs_API", frequency]);

        // Allow it to output
        decoder.stdout.on('data', (data) => { });
        decoder.stderr.on('data', (data) => { });

        decoder.on('close', (code) => {
            if (code == 1) { // Error occured
                callback();
            } else {         // Success
                callback(output);
            }
        });
    }
github acjones617 / scipy-node / optimize / node / engine.js View on Github external
cb = cleanup.callback;
  } else if (operation === 'vectorRoot') {
    var cleanup = clean.cleanVector(a, b, cb, x);
    a = cleanup.func;
    b = JSON.stringify(cleanup.options);
    cb = cleanup.callback;
  } else if (operation === 'derivative') {
    var cleanup = clean.cleanDerivative(a, b, cb, x);
    a = cleanup.func;
    b = JSON.stringify(cleanup.options);
    cb = cleanup.callback;
  }

  // don't need to worry about race conditions with async process below
  // since each is wrapped in their own "runPython" closure
  var python = require('child_process').spawn(
  'python',
  [__dirname + '/../py/exec.py', operation, a, b]);
  var output = '';
  python.stdout.on('data', function (data){
    output += data;
  });
  python.stdout.on('close', function (){
    try {
      cb(JSON.parse(output));
    } catch (e) {
      cb(output);
    }
  });
}
github NativeScript / nativescript-dev-appium / test-runner.js View on Github external
portastic.find({ min: 9200, max: 9300 }).then(function (ports) {
    var port = ports[0];
    server = child_process.spawn(appiumBinary, ["-p", port, "--no-reset"], { detached: false });

    server.stdout.on("data", function (data) {
        logOut("" + data);
    });
    server.stderr.on("data", function (data) {
        logErr("" + data);
    });
    server.on('exit', function (code) {
        server = null;
        logOut('Appium Server process exited with code ' + code);
        process.exit();
    });

    waitForOutput(server, /listener started/, 60000).then(function () {
        process.env.APPIUM_PORT = port;
        tests = child_process.spawn(mochaBinary, mochaOpts, { shell: true, detached: false, env: getTestEnv() });
github appcelerator / titanium_mobile / build / scons-update-node-deps.js View on Github external
exec('npm install --production --force', function (err, stdout, stderr) {
		if (err) {
			console.error(err);
			process.exit(1);
		}

		console.log('\nBuilding node-ios-device binaries');

		var nodeIosDeviceDir = path.join(titaniumDir, 'node_modules', 'node-ios-device');
		var child = spawn('sh', [ path.join(nodeIosDeviceDir, 'bin', 'build-all.sh') ], { cwd: nodeIosDeviceDir, stdio: 'inherit' });

		child.on('close', function (code) {
			if (code) {
				console.error('Error: Failed to build node-ios-device');
				process.exit(1);
			}

			rm(path.join(nodeIosDeviceDir, 'build'));

			console.info('\nCompleted successfully!');
			process.exit(0);
		});
	});
});
github heroku / heroku-container-tools / commands / push.js View on Github external
return new Promise((resolve, reject) => {
    let args = [
      'push',
      resource
    ];
    child.spawn('docker', args, { stdio: 'inherit' })
      .on('exit', (code, signal) => {
        if (signal || code) reject(signal || code);
        else resolve();
      });
  });
}
github react-cosmos / react-cosmos / scripts / build.ts View on Github external
return new Promise((resolve, reject) => {
    const cp = spawn(cmd, args, {
      cwd: path.join(__dirname, '..'),
      env: {
        ...process.env,
        ...env
      },
      shell: true
    });
    cp.stdout.on('data', data => {
      stdout.write(data);
    });
    cp.stderr.on('data', data => {
      stderr.write(data);
    });
    cp.on('close', code => {
      if (code) {
        reject();
github mattermost / desktop / src / main / CriticalErrorHandler.js View on Github external
function openDetachedExternal(url) {
  const spawnOption = {detached: true, stdio: 'ignore'};
  switch (process.platform) {
  case 'win32':
    return spawn('cmd', ['/C', 'start', url], spawnOption);
  case 'darwin':
    return spawn('open', [url], spawnOption);
  case 'linux':
    return spawn('xdg-open', [url], spawnOption);
  default:
    return null;
  }
}
github MattMcFarland / sequelize-relay / scripts / watch.js View on Github external
return new Promise(function (resolve, reject) {
    var child = spawn(command, options, {
      cmd: cmd,
      env: process.env,
      stdio: 'inherit'
    });
    child.on('exit', function (code) {
      if (code === 0) {
        resolve(true);
      } else {
        reject(new Error('Error code: ' + code));
      }
    });
  });
}
github node-pinus / pinus / packages / pinus / lib / master / starter.ts View on Github external
let spawnProcess = function (command: string, host: string, options: string[], cb ?: (result: string | number) => void) {
    let child = null;

    if (env === Constants.RESERVED.ENV_DEV) {
        child = cp.spawn(command, options);
        let prefix = command === Constants.COMMAND.SSH ? '[' + host + '] ' : '';

        child.stderr.on('data', function (chunk) {
            let msg = chunk.toString();
            process.stderr.write(msg);
            if (!!cb) {
                cb(msg);
            }
        });

        child.stdout.on('data', function (chunk) {
            let msg = prefix + chunk.toString();
            process.stdout.write(msg);
        });
    } else {
        child = cp.spawn(command, options, { detached: true, stdio: 'inherit' });

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