more graceful handle stdout

This commit is contained in:
Moon Man 2024-01-30 02:35:37 -05:00
parent 6edec2094f
commit 4fc40aa928
2 changed files with 4 additions and 8 deletions

6
dist/main.js vendored
View File

@ -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) {

View File

@ -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) {