aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/index.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/index.js')
-rw-r--r--src/index.js22
1 files changed, 18 insertions, 4 deletions
diff --git a/src/index.js b/src/index.js
index 72da4d0..bd2a35d 100644
--- a/src/index.js
+++ b/src/index.js
@@ -216,11 +216,27 @@ function rebuild(psModule) {
216 const args = dargs(options.pscIdeArgs) 216 const args = dargs(options.pscIdeArgs)
217 const ideClient = spawn('psc-ide-client', args) 217 const ideClient = spawn('psc-ide-client', args)
218 218
219 ideClient.stdout.once('data', data => { 219 var stdout = ''
220 var stderr = ''
221
222 ideClient.stdout.on('data', data => {
223 stdout = stdout + data.toString()
224 })
225
226 ideClient.stderr.on('data', data => {
227 stderr = stderr + data.toString()
228 })
229
230 ideClient.on('close', code => {
231 if (code !== 0) {
232 const error = stderr === '' ? 'Failed to spawn psc-ide-client' : stderr
233 return reject(new Error(error))
234 }
235
220 let res = null 236 let res = null
221 237
222 try { 238 try {
223 res = JSON.parse(data.toString()) 239 res = JSON.parse(stdout.toString())
224 debug(res) 240 debug(res)
225 } catch (err) { 241 } catch (err) {
226 return reject(err) 242 return reject(err)
@@ -254,8 +270,6 @@ function rebuild(psModule) {
254 }) 270 })
255 }) 271 })
256 272
257 ideClient.stderr.once('data', data => reject(data.toString()))
258
259 ideClient.stdin.write(JSON.stringify(body)) 273 ideClient.stdin.write(JSON.stringify(body))
260 ideClient.stdin.write('\n') 274 ideClient.stdin.write('\n')
261 }) 275 })