Skip to content

Commit

Permalink
Revert "tools: refactor tools/license2rtf to ESM"
Browse files Browse the repository at this point in the history
This reverts commit 30cb1bf.

PR-URL: nodejs/node#43214
Fixes: nodejs/node#43213
Refs: nodejs/node#43101
Reviewed-By: Darshan Sen <raisinten@gmail.com>
Reviewed-By: Beth Griggs <bgriggs@redhat.com>
Reviewed-By: LiviaMedeiros <livia@cirno.name>
Reviewed-By: Rich Trott <rtrott@gmail.com>
  • Loading branch information
richardlau authored May 26, 2022
1 parent cb4a558 commit 331088f
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 15 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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) \
Expand Down
30 changes: 18 additions & 12 deletions tools/license2rtf.mjs → tools/license2rtf.js
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -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);
4 changes: 2 additions & 2 deletions vcbuild.bat
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 331088f

Please sign in to comment.