aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/ChildProcess.purs
diff options
context:
space:
mode:
authoreric <thul.eric@gmail.com>2015-07-18 09:18:01 -0400
committereric <thul.eric@gmail.com>2015-07-18 09:18:01 -0400
commit418c9429609c6d80ddaf7df41e0ee64192e2ec7b (patch)
treecd1ede6128778ececcb371a998dbb628ea539bed /src/ChildProcess.purs
parent52c33a912a2365ef9210778f9db3a0c207bb23d9 (diff)
parente533a3152712876cfdbc5a5579513120fef499fa (diff)
downloadpurs-loader-418c9429609c6d80ddaf7df41e0ee64192e2ec7b.tar.gz
purs-loader-418c9429609c6d80ddaf7df41e0ee64192e2ec7b.tar.zst
purs-loader-418c9429609c6d80ddaf7df41e0ee64192e2ec7b.zip
Merge pull request #19 from ethul/topic/issue-17
Capturing stderr on psc invocation
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}