From 2f55749bcb4bbfd59310c4ff7b431a89367e7c5b Mon Sep 17 00:00:00 2001 From: Nulo Date: Sat, 16 Dec 2023 11:25:46 -0300 Subject: [PATCH] =?UTF-8?q?usar=20api=20mas=20est=C3=A1ndar=20para=20error?= =?UTF-8?q?File?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit funciona en bun --- downloader/download_json.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/downloader/download_json.js b/downloader/download_json.js index 378d50b..0fd2216 100644 --- a/downloader/download_json.js +++ b/downloader/download_json.js @@ -8,6 +8,7 @@ import { TooManyRedirectsError, customRequestWithLimitsAndRetries, } from "./network.js"; +import { createWriteStream } from "node:fs"; let urls = process.argv.slice(2); if (urls.length < 1) { @@ -48,9 +49,9 @@ async function downloadFromData(target) { await mkdir(outputPath, { recursive: true }); await writeFile(join(outputPath, "data.json"), JSON.stringify(json)); await writeFile(join(outputPath, "url.txt"), `${target.type}+${target.url}`); - const errorFile = ( - await open(join(outputPath, "errors.jsonl"), "w") - ).createWriteStream(); + const errorFile = createWriteStream(join(outputPath, "errors.jsonl"), { + flags: "w", + }); try { let nFinished = 0; let nErrors = 0;