From 8141e23ae052c5707a5c69db49fda20123f1b72c Mon Sep 17 00:00:00 2001 From: eric thul Date: Mon, 20 Jul 2015 23:12:58 -0400 Subject: Ensure purescript error is displayed Resolves #24 --- package.json | 1 + src/ChildProcess.purs | 12 +++++++++--- 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 @@ }, "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)(); }); }; -- cgit v1.2.3