aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/compile.js
diff options
context:
space:
mode:
authoreric thul <thul.eric@gmail.com>2017-04-23 14:00:35 -0400
committereric <thul.eric@gmail.com>2017-04-23 18:20:22 -0400
commit7f0547d4e02d927e766de340152a2f75b659d889 (patch)
treed9dd41f5902d81f73ad64772b34291887f4b4fdf /src/compile.js
parent1c12889c0adf91cf3116a9d5ff44b7466b1dfcc9 (diff)
downloadpurs-loader-7f0547d4e02d927e766de340152a2f75b659d889.tar.gz
purs-loader-7f0547d4e02d927e766de340152a2f75b659d889.tar.zst
purs-loader-7f0547d4e02d927e766de340152a2f75b659d889.zip
Refactoring cache usage
Diffstat (limited to 'src/compile.js')
-rw-r--r--src/compile.js19
1 files changed, 13 insertions, 6 deletions
diff --git a/src/compile.js b/src/compile.js
index 8b5d87f..707605c 100644
--- a/src/compile.js
+++ b/src/compile.js
@@ -4,17 +4,17 @@ const Promise = require('bluebird');
4 4
5const spawn = require('cross-spawn'); 5const spawn = require('cross-spawn');
6 6
7const debug = require('debug')('purs-loader'); 7const debug_ = require('debug');
8
9const debug = debug_('purs-loader');
10
11const debugVerbose = debug_('purs-loader:verbose');
8 12
9const dargs = require('./dargs'); 13const dargs = require('./dargs');
10 14
11module.exports = function compile(psModule) { 15module.exports = function compile(psModule) {
12 const options = psModule.options 16 const options = psModule.options
13 17
14 const cache = psModule.cache
15
16 const stderr = []
17
18 const compileCommand = options.psc || 'purs'; 18 const compileCommand = options.psc || 'purs';
19 19
20 const compileArgs = (options.psc ? [] : [ 'compile' ]).concat(dargs(Object.assign({ 20 const compileArgs = (options.psc ? [] : [ 'compile' ]).concat(dargs(Object.assign({
@@ -22,7 +22,9 @@ module.exports = function compile(psModule) {
22 output: options.output, 22 output: options.output,
23 }, options.pscArgs))) 23 }, options.pscArgs)))
24 24
25 debug('spawning compiler %s %o', compileCommand, compileArgs) 25 const stderr = [];
26
27 debug('compile %s %o', compileCommand, compileArgs)
26 28
27 return new Promise((resolve, reject) => { 29 return new Promise((resolve, reject) => {
28 debug('compiling PureScript...') 30 debug('compiling PureScript...')
@@ -33,8 +35,13 @@ module.exports = function compile(psModule) {
33 stderr.push(data.toString()); 35 stderr.push(data.toString());
34 }); 36 });
35 37
38 compilation.stdout.on('data', data => {
39 debugVerbose(data.toString());
40 });
41
36 compilation.on('close', code => { 42 compilation.on('close', code => {
37 debug('finished compiling PureScript.') 43 debug('finished compiling PureScript.')
44
38 if (code !== 0) { 45 if (code !== 0) {
39 const errorMessage = stderr.join(''); 46 const errorMessage = stderr.join('');
40 if (errorMessage.length) { 47 if (errorMessage.length) {