aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/PscIde.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/PscIde.js')
-rw-r--r--src/PscIde.js27
1 files changed, 22 insertions, 5 deletions
diff --git a/src/PscIde.js b/src/PscIde.js
index 8a0e823..bf92b38 100644
--- a/src/PscIde.js
+++ b/src/PscIde.js
@@ -63,15 +63,28 @@ function connect(psModule) {
63 63
64 const serverArgs = dargs(Object.assign({ 64 const serverArgs = dargs(Object.assign({
65 outputDirectory: options.output, 65 outputDirectory: options.output,
66 "_": options.src 66 '_': options.src
67 }, options.pscIdeServerArgs)) 67 }, options.pscIdeServerArgs))
68 68
69 debug('attempting to start psc-ide-server', serverArgs) 69 debug('attempting to start psc-ide-server', serverArgs)
70 70
71 const ideServer = cache.ideServer = spawn('psc-ide-server', serverArgs) 71 const ideServer = cache.ideServer = spawn('psc-ide-server', serverArgs)
72
73 ideServer.stdout.on('data', data => {
74 debug('psc-ide-server stdout: %s', data.toString());
75 });
76
72 ideServer.stderr.on('data', data => { 77 ideServer.stderr.on('data', data => {
73 debug(data.toString()) 78 debug('psc-ide-server stderr: %s', data.toString());
74 }) 79 });
80
81 ideServer.on('error', error => {
82 debug('psc-ide-server error: %o', error);
83 });
84
85 ideServer.on('close', (code, signal) => {
86 debug('psc-ide-server close: %s %s', code, signal);
87 });
75 88
76 return retryPromise((retry, number) => { 89 return retryPromise((retry, number) => {
77 return connect_().catch(error => { 90 return connect_().catch(error => {
@@ -141,16 +154,18 @@ function rebuild(psModule) {
141 .then(compileMessages => { 154 .then(compileMessages => {
142 if (res.resultType === 'error') { 155 if (res.resultType === 'error') {
143 if (res.result.some(item => { 156 if (res.result.some(item => {
157 const isModuleNotFound = item.errorCode === 'ModuleNotFound';
158
144 const isUnknownModule = item.errorCode === 'UnknownModule'; 159 const isUnknownModule = item.errorCode === 'UnknownModule';
145 160
146 const isUnknownModuleImport = item.errorCode === 'UnknownName' && /Unknown module/.test(item.message); 161 const isUnknownModuleImport = item.errorCode === 'UnknownName' && /Unknown module/.test(item.message);
147 162
148 return isUnknownModule || isUnknownModuleImport; 163 return isModuleNotFound || isUnknownModule || isUnknownModuleImport;
149 })) { 164 })) {
150 debug('unknown module, attempting full recompile') 165 debug('unknown module, attempting full recompile')
151 return Psc.compile(psModule) 166 return Psc.compile(psModule)
152 .then(() => PsModuleMap.makeMap(options.src).then(map => { 167 .then(() => PsModuleMap.makeMap(options.src).then(map => {
153 debug('rebuilt module map'); 168 debug('rebuilt module map after unknown module forced a recompile');
154 cache.psModuleMap = map; 169 cache.psModuleMap = map;
155 })) 170 }))
156 .then(() => request({ command: 'load' })) 171 .then(() => request({ command: 'load' }))
@@ -172,6 +187,8 @@ function rebuild(psModule) {
172 }) 187 })
173 }) 188 })
174 189
190 debug('psc-ide-client stdin: %o', body);
191
175 ideClient.stdin.write(JSON.stringify(body)) 192 ideClient.stdin.write(JSON.stringify(body))
176 ideClient.stdin.write('\n') 193 ideClient.stdin.write('\n')
177 }) 194 })