Last active
December 21, 2015 21:58
-
-
Save piscisaureus/6371772 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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