aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAlex Mingoia <talk@alexmingoia.com>2016-05-14 13:55:24 -0700
committerAlex Mingoia <talk@alexmingoia.com>2016-05-14 13:55:24 -0700
commit9dc1021066dea00eb43574e705df383728e667e2 (patch)
tree9638c239aa4c3a8395e6ebca455c54935a11bbf6
parent678884960a53c8c60bbfdfd6389e08580a9ad03e (diff)
downloadpurs-loader-9dc1021066dea00eb43574e705df383728e667e2.tar.gz
purs-loader-9dc1021066dea00eb43574e705df383728e667e2.tar.zst
purs-loader-9dc1021066dea00eb43574e705df383728e667e2.zip
Do not assume line-delimited psc output.
-rw-r--r--src/index.js19
1 files 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) {
65 65
66 // add psc warnings to webpack compilation warnings 66 // add psc warnings to webpack compilation warnings
67 this._compiler.plugin('after-compile', (compilation, callback) => { 67 this._compiler.plugin('after-compile', (compilation, callback) => {
68 if (options.warnings && cache.warnings && cache.warnings.length) { 68 if (options.warnings && cache.warnings) {
69 compilation.warnings.unshift(`PureScript compilation:\n${cache.warnings.join('')}`) 69 compilation.warnings.unshift(`PureScript compilation:\n${cache.warnings}`)
70 } 70 }
71 71
72 if (cache.errors && cache.errors.length) { 72 if (cache.errors) {
73 compilation.errors.unshift(`PureScript compilation:\n${cache.errors.join('\n')}`) 73 compilation.errors.unshift(`PureScript compilation:\n${cache.errors}`)
74 } 74 }
75 75
76 callback() 76 callback()
@@ -184,16 +184,17 @@ function compile(psModule) {
184 184
185 const compilation = spawn(options.psc, args) 185 const compilation = spawn(options.psc, args)
186 186
187 compilation.stdout.on('data', data => stderr.push(data.toString()))
187 compilation.stderr.on('data', data => stderr.push(data.toString())) 188 compilation.stderr.on('data', data => stderr.push(data.toString()))
188 189
189 compilation.on('close', code => { 190 compilation.on('close', code => {
190 console.log('Finished compiling PureScript.') 191 console.log('Finished compiling PureScript.')
191 cache.compilationFinished = true 192 cache.compilationFinished = true
192 if (code !== 0) { 193 if (code !== 0) {
193 cache.compilation = cache.errors = stderr 194 cache.errors = stderr.join('')
194 reject(true) 195 reject(true)
195 } else { 196 } else {
196 cache.compilation = cache.warnings = stderr 197 cache.warnings = stderr.join('')
197 resolve(psModule) 198 resolve(psModule)
198 } 199 }
199 }) 200 })
@@ -245,10 +246,10 @@ function rebuild(psModule) {
245 .then(resolve) 246 .then(resolve)
246 .catch(() => reject('psc-ide rebuild failed')) 247 .catch(() => reject('psc-ide rebuild failed'))
247 } 248 }
248 cache.errors = compileMessages 249 cache.errors = compileMessages.join('\n')
249 reject('psc-ide rebuild failed') 250 reject('psc-ide rebuild failed')
250 } else { 251 } else {
251 cache.warnings = compileMessages 252 cache.warnings = compileMessages.join('\n')
252 resolve(psModule) 253 resolve(psModule)
253 } 254 }
254 }) 255 })
@@ -346,7 +347,7 @@ function bundle(options, cache) {
346 compilation.stderr.on('data', data => stderr.push(data.toString())) 347 compilation.stderr.on('data', data => stderr.push(data.toString()))
347 compilation.on('close', code => { 348 compilation.on('close', code => {
348 if (code !== 0) { 349 if (code !== 0) {
349 cache.errors.concat(stderr) 350 cache.errors = (cache.errors || '') + stderr.join('')
350 return reject(true) 351 return reject(true)
351 } 352 }
352 cache.bundle = stderr 353 cache.bundle = stderr