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 --- src/ChildProcess.purs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'src') 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