diff options
author | eric thul <thul.eric@gmail.com> | 2015-07-18 09:10:59 -0400 |
---|---|---|
committer | eric thul <thul.eric@gmail.com> | 2015-07-18 09:10:59 -0400 |
commit | e533a3152712876cfdbc5a5579513120fef499fa (patch) | |
tree | cd1ede6128778ececcb371a998dbb628ea539bed /src/ChildProcess.purs | |
parent | 52c33a912a2365ef9210778f9db3a0c207bb23d9 (diff) | |
download | purs-loader-e533a3152712876cfdbc5a5579513120fef499fa.tar.gz purs-loader-e533a3152712876cfdbc5a5579513120fef499fa.tar.zst purs-loader-e533a3152712876cfdbc5a5579513120fef499fa.zip |
Capturing stderr on psc invocation
Resolves #17
Diffstat (limited to 'src/ChildProcess.purs')
-rw-r--r-- | src/ChildProcess.purs | 14 |
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 | } |