aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/PscIde.js
diff options
context:
space:
mode:
authoreric <thul.eric@gmail.com>2016-11-19 14:09:12 -0500
committerGitHub <noreply@github.com>2016-11-19 14:09:12 -0500
commit0aa15fbd45950e3f7b43738049b25d1d3e9abc69 (patch)
tree108c0b3403f6b4ff2afbc85eca8532f305c94f77 /src/PscIde.js
parent2d52ea7e4b77a3ea5a8574ca245f51738d22d4a0 (diff)
parent45c62a2c766132a13c546b19025e9c1ef25bcd5b (diff)
downloadpurs-loader-0aa15fbd45950e3f7b43738049b25d1d3e9abc69.tar.gz
purs-loader-0aa15fbd45950e3f7b43738049b25d1d3e9abc69.tar.zst
purs-loader-0aa15fbd45950e3f7b43738049b25d1d3e9abc69.zip
Merge pull request #77 from ethul/topic/psc-ide
Topic/psc ide
Diffstat (limited to 'src/PscIde.js')
-rw-r--r--src/PscIde.js33
1 files changed, 20 insertions, 13 deletions
diff --git a/src/PscIde.js b/src/PscIde.js
index c9d0cfa..27b49f6 100644
--- a/src/PscIde.js
+++ b/src/PscIde.js
@@ -77,10 +77,7 @@ function connect(psModule) {
77 if (!cache.ideServer && number === 9) { 77 if (!cache.ideServer && number === 9) {
78 debug(error) 78 debug(error)
79 79
80 console.log( 80 console.warn('Failed to connect to or start psc-ide-server. A full compilation will occur on rebuild');
81 'failed to connect to or start psc-ide-server, ' +
82 'full compilation will occur on rebuild'
83 )
84 81
85 return Promise.resolve(psModule) 82 return Promise.resolve(psModule)
86 } 83 }
@@ -133,9 +130,7 @@ function rebuild(psModule) {
133 } 130 }
134 131
135 if (res && !Array.isArray(res.result)) { 132 if (res && !Array.isArray(res.result)) {
136 return res.resultType === 'success' 133 return resolve(psModule);
137 ? resolve(psModule)
138 : reject(new Error('psc-ide rebuild failed'))
139 } 134 }
140 135
141 Promise.map(res.result, (item, i) => { 136 Promise.map(res.result, (item, i) => {
@@ -144,7 +139,13 @@ function rebuild(psModule) {
144 }) 139 })
145 .then(compileMessages => { 140 .then(compileMessages => {
146 if (res.resultType === 'error') { 141 if (res.resultType === 'error') {
147 if (res.result.some(item => item.errorCode === 'UnknownModule' || item.errorCode === 'UnknownName')) { 142 if (res.result.some(item => {
143 const isUnknownModule = item.errorCode === 'UnknownModule';
144
145 const isUnknownModuleImport = item.errorCode === 'UnknownName' && /Unknown module/.test(item.message);
146
147 return isUnknownModule || isUnknownModuleImport;
148 })) {
148 debug('unknown module, attempting full recompile') 149 debug('unknown module, attempting full recompile')
149 return Psc.compile(psModule) 150 return Psc.compile(psModule)
150 .then(() => PsModuleMap.makeMap(options.src).then(map => { 151 .then(() => PsModuleMap.makeMap(options.src).then(map => {
@@ -153,13 +154,19 @@ function rebuild(psModule) {
153 })) 154 }))
154 .then(() => request({ command: 'load' })) 155 .then(() => request({ command: 'load' }))
155 .then(resolve) 156 .then(resolve)
156 .catch(() => reject(new Error('psc-ide rebuild failed'))) 157 .catch(() => resolve(psModule))
158 }
159 const errorMessage = compileMessages.join('\n');
160 if (errorMessage.length) {
161 psModule.emitError(errorMessage);
157 } 162 }
158 cache.errors = compileMessages.join('\n') 163 resolve(psModule);
159 reject(new Error('psc-ide rebuild failed'))
160 } else { 164 } else {
161 cache.warnings = compileMessages.join('\n') 165 const warningMessage = compileMessages.join('\n');
162 resolve(psModule) 166 if (options.warnings && warningMessage.length) {
167 psModule.emitWarning(warningMessage);
168 }
169 resolve(psModule);
163 } 170 }
164 }) 171 })
165 }) 172 })