Skip to content

Instantly share code, notes, and snippets.

@piscisaureus
Last active December 21, 2015 21:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save piscisaureus/6371772 to your computer and use it in GitHub Desktop.
Save piscisaureus/6371772 to your computer and use it in GitHub Desktop.
var spawnSync = require('child_process').spawnSync;
var stdio = [
{ type: 'pipe', readable: true, input: new Buffer('Fubar!') },
{ type: 'pipe', writable: true },
{ type: 'pipe', writable: true },
{ type: 'inherit', fd: 0 }
];
var options = {
timeout: 1000,
// -- maxBuffer is a minimum-value, not a precise limit: --
maxBuffer: 12345,
// cwd: '/some/where',
// env: { some: 'key' }
// stdio: stdio,
// OR stdio: 'pipe',
// OR stdio: ['pipe', 'inherit', ...],
// -- This is a short-hand for setting stdio[0].input: --
input: 'This gets echoed back. Aint that fun?',
// uid: null,
// gid: null,
// windowsVerbatimArguments: true,
// -- Encoding is applied to all inputs and outputs: --
encoding: 'utf8'
}
var r = spawnSync('sh', ['-c', 'echo hello && cat'], options);
console.log(r);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment