224
private _listenToStdout(): IDisposable {
225
const onData = (chunk: string | Buffer) => {
227
>
this._buf += text;
228
>
let nl: number;
229
>
while ((nl = this._buf.indexOf('\n')) >= 0) {
230
>
const line = this._buf.slice(0, nl);
231
>
this._buf = this._buf.slice(nl + 1);
232
>
const trimmed = line.trim();
233
>
if (trimmed.length === 0) {
234
continue;
235
}
237
>
try {
238
>
parsed = JSON.parse(trimmed) as WireMessage;
239
>
} catch (err) {
240
this._log('error', `parse error on line: ${trimmed.slice(0, 200)}`);
241
continue;
242
}
244
>
}
245
>
};
246
this._transport.stdout.on('data', onData);
247
return toDisposable(() => this._transport.stdout.off('data', onData));