Skip to content

Commit

Permalink
Revert "Revert "tools: refactor tools/license2rtf to ESM""
Browse files Browse the repository at this point in the history
This reverts commit 331088f.
  • Loading branch information
F3n67u committed May 29, 2022
1 parent bd2cdc5 commit 255c643
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 21 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.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) \
Expand Down
30 changes: 12 additions & 18 deletions tools/license2rtf.js → tools/license2rtf.mjs
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -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,
);
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.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
Expand Down

0 comments on commit 255c643

Please sign in to comment.