From 514ab14654d5809c2485455c875471328238d102 Mon Sep 17 00:00:00 2001 From: eric thul Date: Sat, 19 Nov 2016 12:47:18 -0500 Subject: Update debug statements during build/bundle --- src/Psc.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src/Psc.js') diff --git a/src/Psc.js b/src/Psc.js index 0aa9fe2..437eb91 100644 --- a/src/Psc.js +++ b/src/Psc.js @@ -29,7 +29,7 @@ function compile(psModule) { debug('spawning compiler %s %o', options.psc, args) return (new Promise((resolve, reject) => { - debug('\nCompiling PureScript...') + debug('compiling PureScript...') const compilation = spawn(options.psc, args) @@ -37,7 +37,7 @@ function compile(psModule) { compilation.stderr.on('data', data => stderr.push(data.toString())) compilation.on('close', code => { - debug('Finished compiling PureScript.') + debug('finished compiling PureScript.') cache.compilationFinished = true if (code !== 0) { cache.errors = stderr.join('') @@ -74,13 +74,14 @@ function bundle(options, cache) { debug('spawning bundler %s %o', options.pscBundle, args.join(' ')) return (new Promise((resolve, reject) => { - debug('Bundling PureScript...') + debug('bundling PureScript...') const compilation = spawn(options.pscBundle, args) compilation.stdout.on('data', data => stdout.push(data.toString())) compilation.stderr.on('data', data => stderr.push(data.toString())) compilation.on('close', code => { + debug('finished bundling PureScript.') if (code !== 0) { cache.errors = (cache.errors || '') + stderr.join('') return reject(new Error('bundling failed')) -- cgit v1.2.3 From 45c62a2c766132a13c546b19025e9c1ef25bcd5b Mon Sep 17 00:00:00 2001 From: eric thul Date: Sat, 19 Nov 2016 13:57:32 -0500 Subject: Use emitError and emitWarning --- src/Psc.js | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'src/Psc.js') diff --git a/src/Psc.js b/src/Psc.js index 437eb91..8fe8437 100644 --- a/src/Psc.js +++ b/src/Psc.js @@ -40,10 +40,16 @@ function compile(psModule) { debug('finished compiling PureScript.') cache.compilationFinished = true if (code !== 0) { - cache.errors = stderr.join('') + const errorMessage = stderr.join(''); + if (errorMessage.length) { + psModule.emitError(errorMessage); + } reject(new Error('compilation failed')) } else { - cache.warnings = stderr.join('') + const warningMessage = stderr.join(''); + if (options.warnings && warningMessage.length) { + psModule.emitWarning(warningMessage); + } resolve(psModule) } }) @@ -83,7 +89,10 @@ function bundle(options, cache) { compilation.on('close', code => { debug('finished bundling PureScript.') if (code !== 0) { - cache.errors = (cache.errors || '') + stderr.join('') + const errorMessage = stderr.join(''); + if (errorMessage.length) { + psModule.emitError(errorMessage); + } return reject(new Error('bundling failed')) } cache.bundle = stderr -- cgit v1.2.3