From e533a3152712876cfdbc5a5579513120fef499fa Mon Sep 17 00:00:00 2001 From: eric thul Date: Sat, 18 Jul 2015 09:10:59 -0400 Subject: Capturing stderr on psc invocation Resolves #17 --- src/ChildProcess.purs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/ChildProcess.purs b/src/ChildProcess.purs index c9ff23b..ad4e20f 100644 --- a/src/ChildProcess.purs +++ b/src/ChildProcess.purs @@ -23,13 +23,23 @@ function spawnFn(command, args, errback, callback) { var stdout = new Buffer(0); + var stderr = new Buffer(0); + process.stdout.on('data', function(data){ stdout = Buffer.concat([stdout, new Buffer(data)]); }); + process.stderr.on('data', function(data){ + stderr = Buffer.concat([stderr, new Buffer(data)]); + }); + process.on('close', function(code){ - if (code !== 0) errback(new Error(stdout.toString()))(); - else callback(stdout.toString())(); + var output = stdout.toString(); + + var error = output.length === 0 ? stderr.toString() : output + "\n" + stderr.toString(); + + if (code !== 0) errback(new Error(error))(); + else callback(output)(); }); }; } -- cgit v1.2.3