From cb0ee5d5810d3cef5029a55959c5bc73ba5f75c4 Mon Sep 17 00:00:00 2001 From: Feng Yu Date: Wed, 1 Jun 2022 09:22:11 +0800 Subject: [PATCH] add writable=false and remove the wrapper --- tools/license2rtf.mjs | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/tools/license2rtf.mjs b/tools/license2rtf.mjs index 4cdca33b60995e..d982e679c3e653 100644 --- a/tools/license2rtf.mjs +++ b/tools/license2rtf.mjs @@ -27,6 +27,7 @@ class LineSplitter extends Stream { if (this.buffer) { this.emit('data', this.buffer); } + this.writable = false; this.emit('end'); } } @@ -52,6 +53,7 @@ class ParagraphParser extends Stream { if (data) this.parseLine(data + ''); this.flushParagraph(); + this.writable = false; this.emit('end'); } @@ -211,6 +213,7 @@ class Unwrapper extends Stream { end(data) { if (data) this.write(data); + this.writable = false; this.emit('end'); } } @@ -272,6 +275,7 @@ class RtfGenerator extends Stream { this.write(data); if (this.didWriteAnything) this.emitFooter(); + this.writable = false; this.emit('end'); } @@ -289,15 +293,11 @@ class RtfGenerator extends Stream { stdin.setEncoding('utf-8'); stdin.resume(); -async function main() { - await pipeline( - stdin, - new LineSplitter(), - new ParagraphParser(), - new Unwrapper(), - new RtfGenerator(), - stdout, - ); -} - -main().catch(console.error); +await pipeline( + stdin, + new LineSplitter(), + new ParagraphParser(), + new Unwrapper(), + new RtfGenerator(), + stdout, +);