Skip to content

Instantly share code, notes, and snippets.

@piscisaureus piscisaureus/test.js
Last active Dec 21, 2015

Embed
What would you like to do?
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
You can’t perform that action at this time.