Added support for output with no new line (fix #51)
This commit is contained in:
parent
7e73c686b2
commit
786ed5b3bd
1 changed files with 22 additions and 0 deletions
|
|
@ -227,6 +227,12 @@ export class MI2 extends EventEmitter implements IBackend {
|
||||||
this.onOutput(this.buffer.substr(0, end));
|
this.onOutput(this.buffer.substr(0, end));
|
||||||
this.buffer = this.buffer.substr(end + 1);
|
this.buffer = this.buffer.substr(end + 1);
|
||||||
}
|
}
|
||||||
|
if (this.buffer.length) {
|
||||||
|
if (this.onOutputPartial(this.buffer))
|
||||||
|
{
|
||||||
|
this.buffer = "";
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
stderr(data) {
|
stderr(data) {
|
||||||
|
|
@ -239,6 +245,10 @@ export class MI2 extends EventEmitter implements IBackend {
|
||||||
this.onOutputStderr(this.errbuf.substr(0, end));
|
this.onOutputStderr(this.errbuf.substr(0, end));
|
||||||
this.errbuf = this.errbuf.substr(end + 1);
|
this.errbuf = this.errbuf.substr(end + 1);
|
||||||
}
|
}
|
||||||
|
if (this.errbuf.length) {
|
||||||
|
this.logNoNewLine("stderr", this.errbuf);
|
||||||
|
this.errbuf = "";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onOutputStderr(lines) {
|
onOutputStderr(lines) {
|
||||||
|
|
@ -248,6 +258,14 @@ export class MI2 extends EventEmitter implements IBackend {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onOutputPartial(line) {
|
||||||
|
if (couldBeOutput(line)) {
|
||||||
|
this.logNoNewLine("stdout", line);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
onOutput(lines) {
|
onOutput(lines) {
|
||||||
lines = <string[]>lines.split('\n');
|
lines = <string[]>lines.split('\n');
|
||||||
lines.forEach(line => {
|
lines.forEach(line => {
|
||||||
|
|
@ -537,6 +555,10 @@ export class MI2 extends EventEmitter implements IBackend {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
logNoNewLine(type: string, msg: string) {
|
||||||
|
this.emit("msg", type, msg);
|
||||||
|
}
|
||||||
|
|
||||||
log(type: string, msg: string) {
|
log(type: string, msg: string) {
|
||||||
this.emit("msg", type, msg[msg.length - 1] == '\n' ? msg : (msg + "\n"));
|
this.emit("msg", type, msg[msg.length - 1] == '\n' ? msg : (msg + "\n"));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue