child_process#spawnSync JavaScript Examples

The following examples show how to use child_process#spawnSync. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: render.js    From pastebin-worker with MIT License 5 votes vote down vote up
function getCommitHash() {
  const stdout = spawnSync('git', ['rev-parse', '--short=6', 'HEAD']).stdout
  return stdout === null ? 'unknown' : stdout.toString().trim()
}
Example #2
Source File: cli.js    From freyr-js with Apache License 2.0 5 votes vote down vote up
function check_bin_is_existent(bin, path) {
  const isWin = process.platform === 'win32';
  const command = isWin ? 'where' : 'which';
  const {status} = spawnSync(ensureBinExtIfWindows(isWin, command), [bin], {env: extendPathOnEnv(path)});
  if ([127, null].includes(status)) throw Error(`Unable to locate the command [${command}] within your PATH`);
  return status === 0;
}