From 9dc1021066dea00eb43574e705df383728e667e2 Mon Sep 17 00:00:00 2001 From: Alex Mingoia Date: Sat, 14 May 2016 13:55:24 -0700 Subject: Do not assume line-delimited psc output. --- src/index.js | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/index.js b/src/index.js index 26b0d81..23a99dd 100644 --- a/src/index.js +++ b/src/index.js @@ -65,12 +65,12 @@ module.exports = function purescriptLoader(source, map) { // add psc warnings to webpack compilation warnings this._compiler.plugin('after-compile', (compilation, callback) => { - if (options.warnings && cache.warnings && cache.warnings.length) { - compilation.warnings.unshift(`PureScript compilation:\n${cache.warnings.join('')}`) + if (options.warnings && cache.warnings) { + compilation.warnings.unshift(`PureScript compilation:\n${cache.warnings}`) } - if (cache.errors && cache.errors.length) { - compilation.errors.unshift(`PureScript compilation:\n${cache.errors.join('\n')}`) + if (cache.errors) { + compilation.errors.unshift(`PureScript compilation:\n${cache.errors}`) } callback() @@ -184,16 +184,17 @@ function compile(psModule) { const compilation = spawn(options.psc, args) + compilation.stdout.on('data', data => stderr.push(data.toString())) compilation.stderr.on('data', data => stderr.push(data.toString())) compilation.on('close', code => { console.log('Finished compiling PureScript.') cache.compilationFinished = true if (code !== 0) { - cache.compilation = cache.errors = stderr + cache.errors = stderr.join('') reject(true) } else { - cache.compilation = cache.warnings = stderr + cache.warnings = stderr.join('') resolve(psModule) } }) @@ -245,10 +246,10 @@ function rebuild(psModule) { .then(resolve) .catch(() => reject('psc-ide rebuild failed')) } - cache.errors = compileMessages + cache.errors = compileMessages.join('\n') reject('psc-ide rebuild failed') } else { - cache.warnings = compileMessages + cache.warnings = compileMessages.join('\n') resolve(psModule) } }) @@ -346,7 +347,7 @@ function bundle(options, cache) { compilation.stderr.on('data', data => stderr.push(data.toString())) compilation.on('close', code => { if (code !== 0) { - cache.errors.concat(stderr) + cache.errors = (cache.errors || '') + stderr.join('') return reject(true) } cache.bundle = stderr -- cgit v1.2.3