How to use child-process-promise - 10 common examples

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 PokemonGoers / PredictPokemon-2 / prediction.js View on Github external
function test() {
        var cmd = wekaCmd + ' ' + classifier + ' ' + testOptions
            + ' -l ' + activeModelName  // load the trained model with the specified name
            + ' -T ' + testData;        // test data to be evaluated by the trained model
        return exec(cmd, {maxBuffer: 1024 * 1024 * 2}); // 2MB
    }
github PokemonGoers / PredictPokemon-2 / prediction.js View on Github external
function trainModel() {
        var cmd = wekaCmd + ' ' + classifier + ' ' + classifierOptions + ' ' + trainingOptions
            + ' -t ' + trainingData     // training data to be used to create the model
            + ' -d ' + trainingModelName;       // store the trained model with the specified name
        console.log(cmd);
        return exec(cmd);
    }
github react-materialize / react-materialize / docs / dev.js View on Github external
function runCmd(name, cmd, options) {
  exec(cmd, options)
    .progress(childProcess => {
      listen(childProcess, name);
      processMap[name] = childProcess;
      return;
    })
    .then(() => console.log('Shutdown: '.cyan + name.green))
    .catch(err => {
      if (catchExec(name, err)) {
        // Restart if not explicitly shutdown
        runCmd(name, cmd, options);
      }
    });
}
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 massgov / mayflower / styleguide / tools / gulp / Artifacts.js View on Github external
const commit = function() {
            // We only need to run a commit if the working copy is dirty.
            return exec("git status --porcelain", {cwd: self.resolveDest()})
                .then((res) => {
                    if(res.stdout.trim().length > 0) {
                        return exec(`git add . && git commit -m ${e(self.getCommitMessage())}`, {cwd: self.resolveDest()});
                    }
                });
        };
        const pushBranch = function() {
github zeit / now / src / serverless / builders / nodejs.js View on Github external
// trigger an install if needed
  if (desc.packageJSON) {
    let buildCommand = ''

    if (existsSync(join(targetPath, 'package-lock.json'))) {
      buildCommand = 'npm install'
    } else if (existsSync(join(targetPath, 'yarn.lock'))) {
      buildCommand = 'yarn install'
    } else {
      buildCommand = 'npm install'
    }

    try {
      debug('executing %s in %s', buildCommand, targetPath)
      await exec(buildCommand, {
        cwd: targetPath,
        env: Object.assign({}, process.env, {
          // we set this so that we make the installers ignore
          // dev dependencies. in the future, we can add a flag
          // to ignore this behavior, or set different envs
          NODE_ENV: 'production'
        })
      })
    } catch (err) {
      throw new Error(
        `The build command ${buildCommand} failed for ${dir}: ${err.message}`
      )
    }
  } else {
    debug('ignoring build step, no manifests found')
  }
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 Galarius / vscode-opencl / src / cmd.ts View on Github external
export function execute(command: string): Promise {
    return exec(command, {
        cwd: vscode.workspace.rootPath
    }).then(function(result): Buffer {
        return result.stdout;
    }).fail(function(error) {
        console.error(error);
        let msg = "[Error: " + error.code + "] " + error.stderr;
        vscode.window.showErrorMessage(msg)
        return error
    }).progress(function(childProcess) {
        console.log("Command: " + command + " running...");
    });
}
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;
}

child-process-promise

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

MIT
Latest version published 8 years ago

Package Health Score

56 / 100
Full package analysis

Popular child-process-promise functions