Skip to content

Commit df75546

Browse files
committed
fix: use pipeline()
1 parent f7139bd commit df75546

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/template.mjs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { join, dirname } from "node:path";
22
import { createWriteStream } from "node:fs";
33
import { Readable } from "node:stream";
4+
import { pipeline } from "node:stream/promises";
45
import { mkdir } from "node:fs/promises";
56
import { matcher } from "matching-iterator";
67
import {
@@ -401,10 +402,12 @@ export class Template extends LogLevelMixin(class {}) {
401402
async dump(dest) {
402403
for (const entry of this.#entryCache.values()) {
403404
if (entry.isBlob) {
404-
const d = join(dest, entry.name);
405-
await mkdir(dirname(d), { recursive: true });
406-
const readStream = await entry.readStream;
407-
Readable.fromWeb(readStream).pipe(createWriteStream(d));
405+
const destination = join(dest, entry.name);
406+
await mkdir(dirname(destination), { recursive: true });
407+
await pipeline(
408+
Readable.fromWeb(await entry.stream),
409+
createWriteStream(destination)
410+
);
408411
}
409412
}
410413
}

0 commit comments

Comments
 (0)