Use objectMode

This commit is contained in:
Thibault “Adædra” Hamel 2024-06-24 19:41:51 +02:00
parent 80912cb6e2
commit 6e38e2b0d9
3 changed files with 3 additions and 6 deletions

View File

@ -13,8 +13,7 @@ export default function (manifestName: string) {
const mappings: { [path: string]: string } = {}; const mappings: { [path: string]: string } = {};
return new Transform({ return new Transform({
readableObjectMode: true, objectMode: true,
writableObjectMode: true,
transform(chunk: File, _, callback) { transform(chunk: File, _, callback) {
const hash = PRODUCTION ? fileHash(chunk.contents as Buffer) : "00000000"; const hash = PRODUCTION ? fileHash(chunk.contents as Buffer) : "00000000";
const newName = `${chunk.basename.substring(0, chunk.basename.length - chunk.extname.length)}.${hash.substring(0, 8)}${chunk.extname}`; const newName = `${chunk.basename.substring(0, chunk.basename.length - chunk.extname.length)}.${hash.substring(0, 8)}${chunk.extname}`;

View File

@ -62,8 +62,7 @@ function renderArticle() {
reloadAssets(); reloadAssets();
return new Transform({ return new Transform({
readableObjectMode: true, objectMode: true,
writableObjectMode: true,
async transform(file: File, _, callback) { async transform(file: File, _, callback) {
try { try {
const slug = basename(file.path, ".asciidoc"); const slug = basename(file.path, ".asciidoc");

View File

@ -13,8 +13,7 @@ const FONT_PRESETS = {
function compileFont() { function compileFont() {
return new Transform({ return new Transform({
readableObjectMode: true, objectMode: true,
writableObjectMode: true,
async transform(chunk: File, _, callback) { async transform(chunk: File, _, callback) {
const [, variant, weight] = /([A-Z][a-z]+)-(\w+)\.ttf$/.exec(chunk.basename); const [, variant, weight] = /([A-Z][a-z]+)-(\w+)\.ttf$/.exec(chunk.basename);
const tmpOutput = tmp.fileSync({ discardDescriptor: true }); const tmpOutput = tmp.fileSync({ discardDescriptor: true });