WIP: usar writeStream para guardar archivos

This commit is contained in:
Cat /dev/Nulo 2023-12-18 17:09:20 -03:00
parent eb18951686
commit 6bd70eaa61

View file

@ -9,6 +9,7 @@ import {
customRequestWithLimitsAndRetries,
} from "./network.js";
import { createWriteStream } from "node:fs";
import { pipeline } from "node:stream/promises";
let urls = process.argv.slice(2);
if (urls.length < 1) {
@ -144,7 +145,7 @@ async function downloadDistWithRetries({ dist, dataset, url, outputPath }) {
);
if (!res.body) throw new Error("no body");
await writeFile(filePath, res.body);
await pipeline(res.body, createWriteStream(filePath));
}
/** @typedef DownloadJob