aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Psc.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/Psc.js')
-rw-r--r--src/Psc.js22
1 files changed, 16 insertions, 6 deletions
diff --git a/src/Psc.js b/src/Psc.js
index 0aa9fe2..8fe8437 100644
--- a/src/Psc.js
+++ b/src/Psc.js
@@ -29,7 +29,7 @@ function compile(psModule) {
29 debug('spawning compiler %s %o', options.psc, args) 29 debug('spawning compiler %s %o', options.psc, args)
30 30
31 return (new Promise((resolve, reject) => { 31 return (new Promise((resolve, reject) => {
32 debug('\nCompiling PureScript...') 32 debug('compiling PureScript...')
33 33
34 const compilation = spawn(options.psc, args) 34 const compilation = spawn(options.psc, args)
35 35
@@ -37,13 +37,19 @@ function compile(psModule) {
37 compilation.stderr.on('data', data => stderr.push(data.toString())) 37 compilation.stderr.on('data', data => stderr.push(data.toString()))
38 38
39 compilation.on('close', code => { 39 compilation.on('close', code => {
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 })
@@ -74,15 +80,19 @@ function bundle(options, cache) {
74 debug('spawning bundler %s %o', options.pscBundle, args.join(' ')) 80 debug('spawning bundler %s %o', options.pscBundle, args.join(' '))
75 81
76 return (new Promise((resolve, reject) => { 82 return (new Promise((resolve, reject) => {
77 debug('Bundling PureScript...') 83 debug('bundling PureScript...')
78 84
79 const compilation = spawn(options.pscBundle, args) 85 const compilation = spawn(options.pscBundle, args)
80 86
81 compilation.stdout.on('data', data => stdout.push(data.toString())) 87 compilation.stdout.on('data', data => stdout.push(data.toString()))
82 compilation.stderr.on('data', data => stderr.push(data.toString())) 88 compilation.stderr.on('data', data => stderr.push(data.toString()))
83 compilation.on('close', code => { 89 compilation.on('close', code => {
90 debug('finished bundling PureScript.')
84 if (code !== 0) { 91 if (code !== 0) {
85 cache.errors = (cache.errors || '') + stderr.join('') 92 const errorMessage = stderr.join('');
93 if (errorMessage.length) {
94 psModule.emitError(errorMessage);
95 }
86 return reject(new Error('bundling failed')) 96 return reject(new Error('bundling failed'))
87 } 97 }
88 cache.bundle = stderr 98 cache.bundle = stderr