How to use spawn-command - 3 common examples

To help you get started, we’ve selected a few spawn-command 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 javascriptair / site / other / utils / audio.js View on Github external
return new Promise((resolve, reject) => {
    const command = shellEscape([
      ffmpegPath,
      '-ss', '00:05:00.00',
      '-t', '00:15:00.00',
      '-i', file,
      '-af', 'volumedetect',
      '-f', 'null', '/dev/null',
    ])
    console.log(`Running: ${command}`)

    let buffer = ''
    const options = {stdio: [process.stdin, process.stdout, 'pipe']}
    spawn(command, options)
    .stderr.on('data', data => {
      const chunk = data.toString()
      buffer += chunk
      console.log(chunk)
    })
    .on('error', err => {
      reject(err)
    })
    .on('close', () => {
      const maxVol = /max_volume: (-?[\d\.]+) dB/.exec(buffer)

      if (!maxVol) {
        return resolve({file, episode, gain: 0})
      }

      console.log(`Detected max volume: ${maxVol[1]}dB`)
github javascriptair / site / other / utils / audio.js View on Github external
'-ab', '96k',
    '-ac', '1',
    '-id3v2_version', '3',
    '-write_id3v1', '1',
    '-af', `volume=${gain}dB`,
    '-metadata', `title=${title}`,
    '-metadata', `artist=${artist}`,
    '-metadata', `track=${number}`,
    '-metadata', `date=${year}`,
    '-metadata', 'language=eng',
    '-metadata', `comment=${url}`,
    outputPath,
  ])
  const options = {stdio: 'inherit'}
  console.log(`Running: ${command}`)
  spawn(command, options).on('exit', process.exit)
}
github rocjs / roc / src / execute / index.js View on Github external
return new Promise((resolve, reject) => {
        const cmd = getCommand(command, args);
        const child = spawnCommand(cmd, {
            stdio: silent ? undefined : 'inherit',
            env: getEnv(context),
            cwd,
        });

        child.on('exit', (exitCode) => {
            if (exitCode !== 0) {
                return reject(
                    new ExecuteError(`The command "${cmd}" failed with error code ${exitCode}`, cmd, exitCode)
                );
            }

            return resolve(exitCode);
        });

        child.on('error', (error) =>

spawn-command

Spawn commands like `child_process.exec` does but return a `ChildProcess`

MIT
Latest version published 10 years ago

Package Health Score

65 / 100
Full package analysis

Popular spawn-command functions

Similar packages