How to use the child_process.spawnSync 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 konstellation-io / science-toolkit / vscode / extensions / ms-vscode.go-0.13.0 / out / src / util.js View on Github external
if (process.platform === 'win32') {
        const TASK_KILL = 'C:\\Windows\\System32\\taskkill.exe';
        // when killing a process in Windows its child processes are *not* killed but become root processes.
        // Therefore we use TASKKILL.EXE
        try {
            cp.execSync(`${TASK_KILL} /F /T /PID ${processId}`);
        }
        catch (err) {
            console.log('Error killing process tree: ' + err);
        }
    }
    else {
        // on linux and OS X we kill all direct and indirect child processes as well
        try {
            const cmd = path.join(__dirname, '../../../scripts/terminateProcess.sh');
            cp.spawnSync(cmd, [processId.toString()]);
        }
        catch (err) {
            console.log('Error killing process tree: ' + err);
        }
    }
}
exports.killTree = killTree;
github lozinsky / typescript-babel-jest / tests / helpers / utils.js View on Github external
const run = (cmd, cwd) => {
  const args = cmd.split(/\s/).slice(1);
  const spawnOptions = {cwd};
  const result = spawnSync(cmd.split(/\s/)[0], args, spawnOptions);

  if (result.status !== 0) {
    const message = `
      ORIGINAL CMD: ${cmd}
      STDOUT: ${result.stdout && result.stdout.toString()}
      STDERR: ${result.stderr && result.stderr.toString()}
      STATUS: ${result.status}
      ERROR: ${result.error}
    `;
    throw new Error(message);
  }

  return result;
};
github LinusU / node-appdmg / test / lib / visually-verify-image.js View on Github external
if (!err1 || err1.code !== 'VISUALLY_INCORRECT') {
        return detach()
      }

      captureAndSaveDiff(title, expectedPath, function (err3, res) {
        if (err3) return detach(err3)

        console.error('A diff of the images have been saved to:', res.diff)
        console.error('The actual image have been saved to:', res.actual)
        detach()
      })
    }

    try {
      spawnSync('open', ['-a', 'Finder', mountPath])
    } catch (spawnErr) {
      return done(spawnErr)
    }

    retry(function (cb) {
      captureAndVerify(title, expectedPath, cb)
    }, done)
  })
}
github cneira / zcage / lib / zone.js View on Github external
function ZonesString() {
    var zoneadm = spawnSync('zoneadm', ['list', '-cp']);
    var zones = zoneadm.stdout.toString().split('\n');
    zones.pop();
    return zones;
}
github WeaveTeam / WeaveJS / run-ts.js View on Github external
function run(cmd, args)
{
	console.log('>', cmd, args.join(' '));
	var result = child_process.spawnSync(
		cmd,
		args,
		{
			cwd: process.cwd(),
			env: process.env,
			stdio: 'inherit'
		}
	);
	if (result.error)
		throw result.error;
	return result;
}
github rhdeck / react-native-swift-cli / bin / cli.js View on Github external
.action(function(appname, swiftpath, appprojectpath) {
    validateAppName(appname);
    if (!appprojectpath) appprojectpath = "./" + appname;
    if (["/", "."].indexOf(swiftpath.substring(0, 1)) == -1)
      swiftpath = "./" + swiftpath;
    if (swiftpath.substring(0, 1) != "/") swiftpath = cwd() + "/" + swiftpath;
    if (!fs.existsSync(swiftpath + "/package.json")) {
      console.log("There is no valid project at the path: " + swiftpath + "\n");
      return;
    }
    const swiftjson = require(swiftpath + "/package.json");
    const swiftprojectname = swiftjson.name;

    spawnSync("react-native", ["init", appname, appprojectpath], opts);
    chdir(appprojectpath);
    spawnSync("yarn", ["add", "react-native-swift"], opts);
    spawnSync("yarn", ["link", swiftprojectname], opts);
    spawnSync("yarn", ["add", swiftpath], opts);
    spawnSync(
      "yarn",
      [
        "add",
        "react-native-fix-pod-links",
        "react-native-xcode",
        "react-native-setdevteam",
        "react-native-bundlebase",
        "react-native-fix-ios-version",
        "react-native-camera-ios-enable"
      ],
      opts
    );
    spawnSync("react-native", ["addpodlinks"], opts);
github americanexpress / jest-image-snapshot / src / diff-snapshot.js View on Github external
function runDiffImageToSnapshot(options) {
  options.receivedImageBuffer = options.receivedImageBuffer.toString('base64');

  const serializedInput = JSON.stringify(options);

  let result = {};

  const writeDiffProcess = childProcess.spawnSync(
    process.execPath, [`${__dirname}/diff-process.js`],
    { input: Buffer.from(serializedInput), stdio: ['pipe', 'inherit', 'inherit', 'pipe'] }
  );

  if (writeDiffProcess.status === 0) {
    const output = writeDiffProcess.output[3].toString();
    result = JSON.parse(output);
  } else {
    throw new Error('Error running image diff.');
  }

  return result;
}
github uxmal / reko / src / UserInterfaces / Electron / prepare.js View on Github external
function run_shell(cmd, dir, ...args){
    return child.spawnSync(cmd, args, {
        shell: true,
        cwd: dir,
        stdio:[0,1,2]
    });
}
github angular / material-tools / scripts / release.js View on Github external
function buildDistribution() {
  let result = spawn('node', ['./build.js']);
  return !result.stderr.toString().trim();
}

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