How to use the child-process-promise.spawn function in child-process-promise

To help you get started, we’ve selected a few child-process-promise 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 cs-education / classTranscribe / modules / conversion_utils.js View on Github external
async function detectMuteVideo(pathToFile) {
    const { spawn } = require('child-process-promise');
    // ffprobe -i INPUT -show_streams -select_streams a -loglevel error
    const ffprobe = spawn('ffprobe', ['-i', pathToFile, '-show_streams', '-select_streams', 'a', '-loglevel', 'error']);

    var isMute = true;

    ffprobe.childProcess.stdout.on('data', (data) => {
        isMute = false;
        // console.log(`stdout: ${data}`);
    });

    ffprobe.childProcess.stderr.on('data', (data) => {
        console.log(`stderr: ${data}`);
    });

    try {
        await ffprobe;
        return isMute;
    } catch (err) {
github cs-education / classTranscribe / modules / scraper_utils.js View on Github external
async function requestCookies(publicAccessUrl) {
    console.log("requestCookies");
    const { spawn } = require('child-process-promise');
    const curl = spawn('curl', ['-D', 'cookies.txt', publicAccessUrl]);
    curl.childProcess.stdout.on('data', (data) => {
        console.log(`stdout: ${data}`);
    });

    curl.childProcess.stderr.on('data', (data) => {
        console.log(`stderr: ${data}`);
    });
    await curl;

    var fs  = require('fs-promise');
    return fs.readFile('cookies.txt')
        .then(f => {
            var lines = f.toString().split('\n');
            var Cookies = ['PLAY_SESSION', 'CloudFront-Key-Pair-Id', 'CloudFront-Policy', 'CloudFront-Signature'];
            var value_Cookies = ['', '', '', ''];
            for(var i in lines) {
github shamansir / ielm / cli.js View on Github external
function execInPromise(command, args) {
    //console.log(`:: execute '${command}' with arguments: '${args}'.`);
    const promise = cpp.spawn(command, args || []);
    const childProcess = promise.childProcess;
    childProcess.stdout.on('data', function (data) {
        //console.log(`${command} :: ${data.toString()}`);
    });
    childProcess.stderr.on('data', function (data) {
        console.log(`${command} error :: ${data.toString()}`);
    });
    return promise;
}
github cs-education / classTranscribe / modules / conversion_utils.js View on Github external
async function downloadFile(url, header, dest) {
    console.log('downloadFile');
    console.log(url, header, dest);
    const { spawn } = require('child-process-promise');
    header = header.replace(';','\;');
    const curl = spawn("curl", ["-o", dest, "-O", url, "-H", header, "--silent"]);
    curl.childProcess.stdout.on('data', (data) => {
        console.log(`stdout: ${data}`);
    });

    curl.childProcess.stderr.on('data', (data) => {
        console.log(`stderr: ${data}`);
    });
    await curl;
    return dest;
}
github cs-education / classTranscribe / modules / conversion_utils.js View on Github external
async function convertVideoToWav(pathToFile) {
    console.log("convertVideoToWav");
    var outputFile = _dirname + pathToFile.substring(pathToFile.lastIndexOf('/') + 1, pathToFile.lastIndexOf('.')) + '.wav';
    const { spawn } = require('child-process-promise');
    const ffmpeg = spawn('ffmpeg', ['-nostdin', '-i', pathToFile, '-c:a', 'pcm_s16le', '-ac', '1', '-y', '-ar', '16000', outputFile]);

    ffmpeg.childProcess.stdout.on('data', (data) => {
        console.log(`stdout: ${data}`);
    });

    ffmpeg.childProcess.stderr.on('data', (data) => {
        console.log(`stderr: ${data}`);
    });

    try {
        await ffmpeg;
        return outputFile;
    } catch (err) {
        console.log(err);
        return null;
    }
github plaid / npmserve-server / routes / npm.js View on Github external
const spawnWrapper = function(command, spawnArgs, options, buildDir) {
  const spawnOpts = R.merge(options, {capture: ['stdout', 'stderr']});

  return childProcessPromise.spawn(command, spawnArgs, spawnOpts)
  .then((result) => {
    logger.info('spawnWrapper: ' + command + ' returned');
    return Promise.all([
      fs.writeFileAsync(path.join(buildDir, command + '.out'), result.stdout),
      fs.writeFileAsync(path.join(buildDir, command + '.err'), result.stderr)
    ]);
  });
};
github atlassian / nucleus / src / files / linuxHelpers.ts View on Github external
const spawnPromiseAndCapture = async (command: string, args: string[], opts: any = {}): Promise<[Buffer, Buffer, Error | null]> => {
  const stdout: Buffer[] = [];
  const stderr: Buffer[] = [];
  const child = cp.spawn(command, args, opts);
  child.childProcess.stdout.on('data', (data: Buffer) => stdout.push(data));
  child.childProcess.stderr.on('data', (data: Buffer) => stderr.push(data));
  let error: Error | null = null;
  try {
    await child;
  } catch (err) {
    error = err;
  }
  return [Buffer.concat(stdout), Buffer.concat(stderr), error];
};
github atlassian / nucleus / src / files / utils / spawn.ts View on Github external
export const spawnPromiseAndCapture = async (command: string, args: string[], opts: any = {}): Promise<[Buffer, Buffer, Error | null]> => {
  const stdout: Buffer[] = [];
  const stderr: Buffer[] = [];
  const child = cp.spawn(command, args, opts);
  child.childProcess.stdout.on('data', (data: Buffer) => stdout.push(data));
  child.childProcess.stderr.on('data', (data: Buffer) => stderr.push(data));
  let error: Error | null = null;
  try {
    await child;
  } catch (err) {
    error = err;
  }
  return [Buffer.concat(stdout), Buffer.concat(stderr), error];
};
github shoutem / cli / src / services / npm.js View on Github external
export async function install(cwd = process.cwd()) {
  await spawn('npm', ['install'], {
    cwd,
    stdio: 'inherit',
    shell: true,
    env: { ...process.env, FORCE_COLOR: true }
  });
}

child-process-promise

Simple wrapper around the "child_process" module that makes use of promises

MIT
Latest version published 7 years ago

Package Health Score

56 / 100
Full package analysis

Popular child-process-promise functions