Skip to content

Commit

Permalink
tools: refactor license2rtf.js to ESM
Browse files Browse the repository at this point in the history
  • Loading branch information
F3n67u authored and yufeng.freeman committed May 16, 2022
1 parent aa14ff9 commit e31032d
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 17 deletions.
2 changes: 1 addition & 1 deletion Makefile
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
26 changes: 12 additions & 14 deletions tools/license2rtf.js → tools/license2rtf.mjs
@@ -1,7 +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 process from 'node:process';


/*
Expand Down Expand Up @@ -287,19 +287,17 @@ 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
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 e31032d

Please sign in to comment.