diff options
author | Feng Yu <F3n67u@outlook.com> | 2022-05-25 18:11:42 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-05-25 18:11:42 +0300 |
commit | 30cb1bf8b8594e3ec8aa9b9b7a7220fe1cc9c926 (patch) | |
tree | e6b0112fb20f7d6eacc70b00e7a542b6b04572ec | |
parent | b5ed1bd33aed3d30b1e5c9dbf0e7e7785e3a6631 (diff) |
tools: refactor `tools/license2rtf` to ESM
PR-URL: https://github.com/nodejs/node/pull/43101
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Minwoo Jung <nodecorelab@gmail.com>
Reviewed-By: Darshan Sen <raisinten@gmail.com>
-rw-r--r-- | Makefile | 2 | ||||
-rw-r--r-- | tools/license2rtf.mjs (renamed from tools/license2rtf.js) | 30 | ||||
-rw-r--r-- | vcbuild.bat | 4 |
3 files changed, 15 insertions, 21 deletions
@@ -1096,7 +1096,7 @@ endif $(MACOSOUTDIR)/dist/npm/usr/local/lib/node_modules unlink $(MACOSOUTDIR)/dist/node/usr/local/bin/npm unlink $(MACOSOUTDIR)/dist/node/usr/local/bin/npx - $(NODE) tools/license2rtf.js < LICENSE > \ + $(NODE) tools/license2rtf.mjs < LICENSE > \ $(MACOSOUTDIR)/installer/productbuild/Resources/license.rtf cp doc/osx_installer_logo.png $(MACOSOUTDIR)/installer/productbuild/Resources pkgbuild --version $(FULLVERSION) \ diff --git a/tools/license2rtf.js b/tools/license2rtf.mjs index 817da81d7a6..0772b161ed0 100644 --- a/tools/license2rtf.js +++ b/tools/license2rtf.mjs @@ -1,8 +1,7 @@ -'use strict'; - -const assert = require('assert'); -const Stream = require('stream'); - +import assert from 'node:assert'; +import Stream from 'node:stream'; +import { pipeline } from 'node:stream/promises'; +import { stdin, stdout } from 'node:process'; /* * This filter consumes a stream of characters and emits one string per line. @@ -287,19 +286,14 @@ class RtfGenerator extends Stream { } } - -const stdin = process.stdin; -const stdout = process.stdout; -const lineSplitter = new LineSplitter(); -const paragraphParser = new ParagraphParser(); -const unwrapper = new Unwrapper(); -const rtfGenerator = new RtfGenerator(); - stdin.setEncoding('utf-8'); stdin.resume(); -stdin.pipe(lineSplitter); -lineSplitter.pipe(paragraphParser); -paragraphParser.pipe(unwrapper); -unwrapper.pipe(rtfGenerator); -rtfGenerator.pipe(stdout); +await pipeline( + stdin, + new LineSplitter(), + new ParagraphParser(), + new Unwrapper(), + new RtfGenerator(), + stdout, +); diff --git a/vcbuild.bat b/vcbuild.bat index 49fa899de71..f0fca0ad713 100644 --- a/vcbuild.bat +++ b/vcbuild.bat @@ -420,9 +420,9 @@ if "%use_x64_node_exe%"=="true" ( set exit_code=1 goto exit ) - %x64_node_exe% tools\license2rtf.js < LICENSE > %config%\license.rtf + %x64_node_exe% tools\license2rtf.mjs < LICENSE > %config%\license.rtf ) else ( - %node_exe% tools\license2rtf.js < LICENSE > %config%\license.rtf + %node_exe% tools\license2rtf.mjs < LICENSE > %config%\license.rtf ) if errorlevel 1 echo Failed to generate license.rtf&goto exit |