aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/ChildProcess.purs
diff options
context:
space:
mode:
Diffstat (limited to 'src/ChildProcess.purs')
-rw-r--r--src/ChildProcess.purs14
1 files changed, 12 insertions, 2 deletions
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) {
23 23
24 var stdout = new Buffer(0); 24 var stdout = new Buffer(0);
25 25
26 var stderr = new Buffer(0);
27
26 process.stdout.on('data', function(data){ 28 process.stdout.on('data', function(data){
27 stdout = Buffer.concat([stdout, new Buffer(data)]); 29 stdout = Buffer.concat([stdout, new Buffer(data)]);
28 }); 30 });
29 31
32 process.stderr.on('data', function(data){
33 stderr = Buffer.concat([stderr, new Buffer(data)]);
34 });
35
30 process.on('close', function(code){ 36 process.on('close', function(code){
31 if (code !== 0) errback(new Error(stdout.toString()))(); 37 var output = stdout.toString();
32 else callback(stdout.toString())(); 38
39 var error = output.length === 0 ? stderr.toString() : output + "\n" + stderr.toString();
40
41 if (code !== 0) errback(new Error(error))();
42 else callback(output)();
33 }); 43 });
34 }; 44 };
35} 45}