Skip to content

Instantly share code, notes, and snippets.

@ORESoftware
Last active January 29, 2018 08:26
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ORESoftware/7bf225f0045b4649de6848f1ea5def4c to your computer and use it in GitHub Desktop.
Save ORESoftware/7bf225f0045b4649de6848f1ea5def4c to your computer and use it in GitHub Desktop.
generic way to spawn
// the old way
const cp = require('child_process');
const k = cp.spawn('npm', ['install','lodash']);
k.stdout.on('data', yourHandlerHere);
// the more generic way
const cp = require('child_process');
const k = cp.spawn('bash');
k.stdout.on('data', yourHandlerHere);
k.stdin.write('npm install lodash');
k.stdin.end('\n');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment