aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authoreric <thul.eric@gmail.com>2015-07-20 23:19:59 -0400
committereric <thul.eric@gmail.com>2015-07-20 23:19:59 -0400
commitfa8110b6b6eaf9d3d2acbb3486afe8e717a11e14 (patch)
tree2180c255850fcb22db8c00b82c1bd5fa28c5e87f
parent65f987291a0773096d8a0f9a1158f472e641bfc4 (diff)
parent8141e23ae052c5707a5c69db49fda20123f1b72c (diff)
downloadpurs-loader-fa8110b6b6eaf9d3d2acbb3486afe8e717a11e14.tar.gz
purs-loader-fa8110b6b6eaf9d3d2acbb3486afe8e717a11e14.tar.zst
purs-loader-fa8110b6b6eaf9d3d2acbb3486afe8e717a11e14.zip
Merge pull request #25 from ethul/topic/issue-24
Ensure purescript error is displayed
-rw-r--r--package.json1
-rw-r--r--src/ChildProcess.purs12
2 files changed, 10 insertions, 3 deletions
diff --git a/package.json b/package.json
index d4159a5..46a37ae 100644
--- a/package.json
+++ b/package.json
@@ -29,6 +29,7 @@
29 }, 29 },
30 "dependencies": { 30 "dependencies": {
31 "async": "^1.3.0", 31 "async": "^1.3.0",
32 "chalk": "^1.1.0",
32 "glob": "^5.0.3", 33 "glob": "^5.0.3",
33 "loader-utils": "^0.2.6" 34 "loader-utils": "^0.2.6"
34 } 35 }
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 };