const spawnSync = require('child_process').spawnSync;
let x = spawnSync('bash', ['-c', 'echo "1stdout" ; echo "2stderr" >&2 ; echo "3stdout"']);
(The bash
command is only an example. The command could be ls
or wget
or git
- doesn't matter.)
Of course, I can access stdout
of the subprocess with x.stdout
and stderr
with x.stderr
so I will get
1stdout
3stdout
and
2stderr
respectively. However, what I want is a single variable which contains
1stdout
2stderr
3stdout
I have a feeling that there is something in options.stdio
which could help, but I wasn't able to figure it out.