mirror of
https://github.com/nodejs/node.git
synced 2026-11-30 11:55:44 -05:00
tools: refactor tools/license2rtf to ESM
This reverts commit 331088f4a4.
PR-URL: https://github.com/nodejs/node/pull/43232
Refs: https://github.com/nodejs/node/issues/43213
Reviewed-By: Darshan Sen <raisinten@gmail.com>
Reviewed-By: LiviaMedeiros <livia@cirno.name>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
This commit is contained in:
1 parent
4176671a91
commit
a42099564c
3 files changed
+22
-24
No files matched your search
@@ -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) \
|
||||
|
||||
@@ -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.
|
||||
@@ -28,6 +27,7 @@ class LineSplitter extends Stream {
|
||||
if (this.buffer) {
|
||||
this.emit('data', this.buffer);
|
||||
}
|
||||
this.writable = false;
|
||||
this.emit('end');
|
||||
}
|
||||
}
|
||||
@@ -53,6 +53,7 @@ class ParagraphParser extends Stream {
|
||||
if (data)
|
||||
this.parseLine(data + '');
|
||||
this.flushParagraph();
|
||||
this.writable = false;
|
||||
this.emit('end');
|
||||
}
|
||||
|
||||
@@ -212,6 +213,7 @@ class Unwrapper extends Stream {
|
||||
end(data) {
|
||||
if (data)
|
||||
this.write(data);
|
||||
this.writable = false;
|
||||
this.emit('end');
|
||||
}
|
||||
}
|
||||
@@ -273,6 +275,7 @@ class RtfGenerator extends Stream {
|
||||
this.write(data);
|
||||
if (this.didWriteAnything)
|
||||
this.emitFooter();
|
||||
this.writable = false;
|
||||
this.emit('end');
|
||||
}
|
||||
|
||||
@@ -287,19 +290,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,
|
||||
);
|
||||
+5
-5
@@ -405,7 +405,7 @@ if errorlevel 1 echo "Could not create junction to 'out\%config%'." & exit /B
|
||||
if not defined sign goto licensertf
|
||||
|
||||
call tools\sign.bat Release\node.exe
|
||||
if errorlevel 1 echo Failed to sign exe&goto exit
|
||||
if errorlevel 1 echo Failed to sign exe, got error code %errorlevel%&goto exit
|
||||
|
||||
:licensertf
|
||||
@rem Skip license.rtf generation if not requested.
|
||||
@@ -426,12 +426,12 @@ 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
|
||||
if errorlevel 1 echo Failed to generate license.rtf, got error code %errorlevel%&goto exit
|
||||
|
||||
:stage_package
|
||||
if not defined stage_package goto install-doctools
|
||||
@@ -538,7 +538,7 @@ if errorlevel 1 goto exit
|
||||
|
||||
if not defined sign goto upload
|
||||
call tools\sign.bat node-v%FULLVERSION%-%target_arch%.msi
|
||||
if errorlevel 1 echo Failed to sign msi&goto exit
|
||||
if errorlevel 1 echo Failed to sign msi, got error code %errorlevel%&goto exit
|
||||
|
||||
:upload
|
||||
@rem Skip upload if not requested
|
||||
|
||||
Reference in new issue
Block a user