more graceful handle stdout
This commit is contained in:
parent
6edec2094f
commit
4fc40aa928
|
@ -39,10 +39,8 @@ export class Port extends Duplex {
|
||||||
const term = this.bert.encode(obj, true);
|
const term = this.bert.encode(obj, true);
|
||||||
const len = Buffer.alloc(4);
|
const len = Buffer.alloc(4);
|
||||||
len.writeUInt32BE(term.length, 0);
|
len.writeUInt32BE(term.length, 0);
|
||||||
process.stdout.write = this.originalStdout;
|
this.originalStdout.write(len);
|
||||||
process.stdout.write(len);
|
this.originalStdout.write(term, actualCallback);
|
||||||
process.stdout.write(term, actualCallback);
|
|
||||||
process.stdout.write = this.fakeStdout;
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
catch (error) {
|
catch (error) {
|
||||||
|
|
|
@ -51,10 +51,8 @@ export class Port extends Duplex {
|
||||||
const len = Buffer.alloc(4);
|
const len = Buffer.alloc(4);
|
||||||
len.writeUInt32BE(term.length, 0);
|
len.writeUInt32BE(term.length, 0);
|
||||||
|
|
||||||
process.stdout.write = this.originalStdout as any;
|
this.originalStdout.write(len);
|
||||||
process.stdout.write(len);
|
this.originalStdout.write(term, actualCallback);
|
||||||
process.stdout.write(term, actualCallback);
|
|
||||||
process.stdout.write = this.fakeStdout;
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
catch (error) {
|
catch (error) {
|
||||||
|
|
Loading…
Reference in New Issue