diff options
author | eric <thul.eric@gmail.com> | 2015-07-20 23:19:59 -0400 |
---|---|---|
committer | eric <thul.eric@gmail.com> | 2015-07-20 23:19:59 -0400 |
commit | fa8110b6b6eaf9d3d2acbb3486afe8e717a11e14 (patch) | |
tree | 2180c255850fcb22db8c00b82c1bd5fa28c5e87f /src/ChildProcess.purs | |
parent | 65f987291a0773096d8a0f9a1158f472e641bfc4 (diff) | |
parent | 8141e23ae052c5707a5c69db49fda20123f1b72c (diff) | |
download | purs-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
Diffstat (limited to 'src/ChildProcess.purs')
-rw-r--r-- | src/ChildProcess.purs | 12 |
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 | }; |