I have this code:
var convert = spawn("gm", ["convert"].concat(parameters));
// output stream
obj.outStream = new BufferList();
convert.stderr.pipe(process.stderr, { end: false });
// put the output in the stream TOO
convert.stdout.pipe(obj.outStream);
// send the image to the input
obj.stream.pipe(throttle).pipe(convert.stdin);
How can I suppress the output of the "convert" process, without suppressing the input and the output to obj.outStream too?
The reason is because I don't want to output that to the user, as it does now.
What you're probably seeing in the output is convert.stderr
because you are piping it to process.stderr
, which is the error output of your child process' master. When you spawn a child process, by default, no stdio
is handled.
var spawn = require('child_process').spawn'
var child = spawn('gm', ['convert']);
The code that you've shown is that you're directly piping the child's stderr
to the main process' stderr
and piping stdout
to your outStream
. That means the only possible output you can see is convert.stderr
.
To fix this, ignore stderr
.
var obj = {
outStream: new BufferList()
};
var spawn = require('child_process').spawn'
var child = spawn('gm', ['convert'], {
stdio: ['pipe', obj.outStream, 'ignore']
});
With this, you have the stdin
stream as it normally is, stdout
piped to obj.outStream
m and stderr
ignored.