From 331088f4a450e29f3ea8a28a9f98ccc9f8951386 Mon Sep 17 00:00:00 2001 From: Richard Lau Date: Thu, 26 May 2022 17:03:12 +0100 Subject: [PATCH] Revert "tools: refactor `tools/license2rtf` to ESM" This reverts commit 30cb1bf8b8594e3ec8aa9b9b7a7220fe1cc9c926. PR-URL: https://github.com/nodejs/node/pull/43214 Fixes: https://github.com/nodejs/node/issues/43213 Refs: https://github.com/nodejs/node/pull/43101 Reviewed-By: Darshan Sen Reviewed-By: Beth Griggs Reviewed-By: LiviaMedeiros Reviewed-By: Rich Trott --- Makefile | 2 +- tools/{license2rtf.mjs => license2rtf.js} | 30 ++++++++++++++--------- vcbuild.bat | 4 +-- 3 files changed, 21 insertions(+), 15 deletions(-) rename tools/{license2rtf.mjs => license2rtf.js} (94%) diff --git a/Makefile b/Makefile index aef13c270516e6..9f7ab7129d0647 100644 --- a/Makefile +++ b/Makefile @@ -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.mjs < LICENSE > \ + $(NODE) tools/license2rtf.js < 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.mjs b/tools/license2rtf.js similarity index 94% rename from tools/license2rtf.mjs rename to tools/license2rtf.js index 0772b161ed06b1..817da81d7a6ada 100644 --- a/tools/license2rtf.mjs +++ b/tools/license2rtf.js @@ -1,7 +1,8 @@ -import assert from 'node:assert'; -import Stream from 'node:stream'; -import { pipeline } from 'node:stream/promises'; -import { stdin, stdout } from 'node:process'; +'use strict'; + +const assert = require('assert'); +const Stream = require('stream'); + /* * This filter consumes a stream of characters and emits one string per line. @@ -286,14 +287,19 @@ 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(); -await pipeline( - stdin, - new LineSplitter(), - new ParagraphParser(), - new Unwrapper(), - new RtfGenerator(), - stdout, -); +stdin.pipe(lineSplitter); +lineSplitter.pipe(paragraphParser); +paragraphParser.pipe(unwrapper); +unwrapper.pipe(rtfGenerator); +rtfGenerator.pipe(stdout); diff --git a/vcbuild.bat b/vcbuild.bat index f0fca0ad7136ae..49fa899de7178e 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.mjs < LICENSE > %config%\license.rtf + %x64_node_exe% tools\license2rtf.js < LICENSE > %config%\license.rtf ) else ( - %node_exe% tools\license2rtf.mjs < LICENSE > %config%\license.rtf + %node_exe% tools\license2rtf.js < LICENSE > %config%\license.rtf ) if errorlevel 1 echo Failed to generate license.rtf&goto exit