aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Psc.js
diff options
context:
space:
mode:
authoreric thul <thul.eric@gmail.com>2016-11-19 13:57:32 -0500
committereric thul <thul.eric@gmail.com>2016-11-19 13:57:32 -0500
commit45c62a2c766132a13c546b19025e9c1ef25bcd5b (patch)
tree108c0b3403f6b4ff2afbc85eca8532f305c94f77 /src/Psc.js
parent28124e28f18c5aae38e149a3fc9624b46a906281 (diff)
downloadpurs-loader-45c62a2c766132a13c546b19025e9c1ef25bcd5b.tar.gz
purs-loader-45c62a2c766132a13c546b19025e9c1ef25bcd5b.tar.zst
purs-loader-45c62a2c766132a13c546b19025e9c1ef25bcd5b.zip
Use emitError and emitWarning
Diffstat (limited to 'src/Psc.js')
-rw-r--r--src/Psc.js15
1 files changed, 12 insertions, 3 deletions
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) {
40 debug('finished compiling PureScript.') 40 debug('finished compiling PureScript.')
41 cache.compilationFinished = true 41 cache.compilationFinished = true
42 if (code !== 0) { 42 if (code !== 0) {
43 cache.errors = stderr.join('') 43 const errorMessage = stderr.join('');
44 if (errorMessage.length) {
45 psModule.emitError(errorMessage);
46 }
44 reject(new Error('compilation failed')) 47 reject(new Error('compilation failed'))
45 } else { 48 } else {
46 cache.warnings = stderr.join('') 49 const warningMessage = stderr.join('');
50 if (options.warnings && warningMessage.length) {
51 psModule.emitWarning(warningMessage);
52 }
47 resolve(psModule) 53 resolve(psModule)
48 } 54 }
49 }) 55 })
@@ -83,7 +89,10 @@ function bundle(options, cache) {
83 compilation.on('close', code => { 89 compilation.on('close', code => {
84 debug('finished bundling PureScript.') 90 debug('finished bundling PureScript.')
85 if (code !== 0) { 91 if (code !== 0) {
86 cache.errors = (cache.errors || '') + stderr.join('') 92 const errorMessage = stderr.join('');
93 if (errorMessage.length) {
94 psModule.emitError(errorMessage);
95 }
87 return reject(new Error('bundling failed')) 96 return reject(new Error('bundling failed'))
88 } 97 }
89 cache.bundle = stderr 98 cache.bundle = stderr