aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authoreric thul <thul.eric@gmail.com>2015-07-20 23:12:58 -0400
committereric thul <thul.eric@gmail.com>2015-07-20 23:12:58 -0400
commit8141e23ae052c5707a5c69db49fda20123f1b72c (patch)
tree2180c255850fcb22db8c00b82c1bd5fa28c5e87f /src
parent65f987291a0773096d8a0f9a1158f472e641bfc4 (diff)
downloadpurs-loader-8141e23ae052c5707a5c69db49fda20123f1b72c.tar.gz
purs-loader-8141e23ae052c5707a5c69db49fda20123f1b72c.tar.zst
purs-loader-8141e23ae052c5707a5c69db49fda20123f1b72c.zip
Ensure purescript error is displayed
Resolves #24
Diffstat (limited to 'src')
-rw-r--r--src/ChildProcess.purs12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/ChildProcess.purs b/src/ChildProcess.purs
index ad4e20f..34558fa 100644
--- a/src/ChildProcess.purs
+++ b/src/ChildProcess.purs
@@ -34,11 +34,17 @@ function spawnFn(command, args, errback, callback) {
34 }); 34 });
35 35
36 process.on('close', function(code){ 36 process.on('close', function(code){
37 var output = stdout.toString(); 37 var chalk = require('chalk');
38 38
39 var error = output.length === 0 ? stderr.toString() : output + "\n" + stderr.toString(); 39 var output = stdout.toString('utf-8');
40 40
41 if (code !== 0) errback(new Error(error))(); 41 var error = stderr.toString('utf-8');
42
43 if (error.length > 0) {
44 console.error('\n' + chalk.red('*') + ' ' + error);
45 }
46
47 if (code !== 0) errback(new Error('Process terminated with code ' + code))();
42 else callback(output)(); 48 else callback(output)();
43 }); 49 });
44 }; 50 };