use hand-crafted promise, pipeline does not resolve properly
This commit is contained in:
@ -1,5 +1,4 @@
|
|||||||
import { Readable, Transform } from "stream";
|
import { Readable, Transform } from "stream";
|
||||||
import { pipeline } from "stream/promises";
|
|
||||||
import { dirname, relative, sep } from "path";
|
import { dirname, relative, sep } from "path";
|
||||||
import { createWriteStream } from "fs";
|
import { createWriteStream } from "fs";
|
||||||
|
|
||||||
@ -71,19 +70,20 @@ export default async function jar({ groupId, artifactId, version, rootPath, targ
|
|||||||
});
|
});
|
||||||
|
|
||||||
await mkdir(dirname(targetPath), { recursive: true });
|
await mkdir(dirname(targetPath), { recursive: true });
|
||||||
/**
|
|
||||||
* Create an async pipeline, wait until everything is fully processed
|
// Create an async pipeline, wait until everything is fully processed
|
||||||
*/
|
await new Promise<void>((resolve, reject) => {
|
||||||
await pipeline(
|
|
||||||
// walk all files in `rootPath` recursively
|
// walk all files in `rootPath` recursively
|
||||||
Readable.from(walk(rootPath)),
|
Readable.from(walk(rootPath))
|
||||||
// transform every path into a ZipSource object
|
// transform every path into a ZipSource object
|
||||||
pathToRecord(),
|
.pipe(pathToRecord())
|
||||||
// let the zip lib convert all ZipSource objects into a byte stream
|
// let the zip lib convert all ZipSource objects into a byte stream
|
||||||
zip(),
|
.pipe(zip())
|
||||||
// write that byte stream to targetPath
|
// write that byte stream to targetPath
|
||||||
createWriteStream(targetPath, { encoding: "binary" })
|
.pipe(createWriteStream(targetPath, { encoding: "binary" }))
|
||||||
);
|
.on("finish", () => resolve())
|
||||||
|
.on("error", e => reject(e));
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Reference in New Issue
Block a user