From: eric thul Date: Tue, 21 Jul 2015 03:12:58 +0000 (-0400) Subject: Ensure purescript error is displayed X-Git-Tag: 0.3.2~1^2 X-Git-Url: https://git.immae.eu/?a=commitdiff_plain;h=8141e23ae052c5707a5c69db49fda20123f1b72c;p=github%2Ffretlink%2Fpurs-loader.git Ensure purescript error is displayed Resolves #24 --- diff --git a/package.json b/package.json index d4159a5..46a37ae 100644 --- a/package.json +++ b/package.json @@ -29,6 +29,7 @@ }, "dependencies": { "async": "^1.3.0", + "chalk": "^1.1.0", "glob": "^5.0.3", "loader-utils": "^0.2.6" } 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) { }); process.on('close', function(code){ - var output = stdout.toString(); + var chalk = require('chalk'); - var error = output.length === 0 ? stderr.toString() : output + "\n" + stderr.toString(); + var output = stdout.toString('utf-8'); - if (code !== 0) errback(new Error(error))(); + var error = stderr.toString('utf-8'); + + if (error.length > 0) { + console.error('\n' + chalk.red('*') + ' ' + error); + } + + if (code !== 0) errback(new Error('Process terminated with code ' + code))(); else callback(output)(); }); };