From 38ad47ea75b61cb6d5842f562a0924e4254c8212 Mon Sep 17 00:00:00 2001 From: Waldemar Reusch Date: Sun, 5 Feb 2023 13:32:24 +0100 Subject: [PATCH] use hand-crafted promise, pipeline does not resolve properly --- src/bin/tools/jar.ts | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/bin/tools/jar.ts b/src/bin/tools/jar.ts index 62c99288..2dc60f0e 100644 --- a/src/bin/tools/jar.ts +++ b/src/bin/tools/jar.ts @@ -1,5 +1,4 @@ import { Readable, Transform } from "stream"; -import { pipeline } from "stream/promises"; import { dirname, relative, sep } from "path"; import { createWriteStream } from "fs"; @@ -71,19 +70,20 @@ export default async function jar({ groupId, artifactId, version, rootPath, targ }); await mkdir(dirname(targetPath), { recursive: true }); - /** - * Create an async pipeline, wait until everything is fully processed - */ - await pipeline( + + // Create an async pipeline, wait until everything is fully processed + await new Promise((resolve, reject) => { // walk all files in `rootPath` recursively - Readable.from(walk(rootPath)), - // transform every path into a ZipSource object - pathToRecord(), - // let the zip lib convert all ZipSource objects into a byte stream - zip(), - // write that byte stream to targetPath - createWriteStream(targetPath, { encoding: "binary" }) - ); + Readable.from(walk(rootPath)) + // transform every path into a ZipSource object + .pipe(pathToRecord()) + // let the zip lib convert all ZipSource objects into a byte stream + .pipe(zip()) + // write that byte stream to targetPath + .pipe(createWriteStream(targetPath, { encoding: "binary" })) + .on("finish", () => resolve()) + .on("error", e => reject(e)); + }); } /**