From 37756fbf3cd6aad6dad00f5e094dc0e2d372b1a8 Mon Sep 17 00:00:00 2001 From: Nulo Date: Sat, 9 Dec 2023 17:10:10 -0300 Subject: [PATCH] arreglar sistema de varios tipos de target --- downloader/download_json.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/downloader/download_json.js b/downloader/download_json.js index 41f46b5..1f1e428 100644 --- a/downloader/download_json.js +++ b/downloader/download_json.js @@ -30,19 +30,19 @@ let urls = process.argv.slice(2); if (urls.length < 1) { urls = targetsPorDefecto; } -/** @typedef {{type: "data.json" | "ckan"; url: string;}} Target */ +/** @typedef {{type: "datajson" | "ckan"; url: string;}} Target */ /** @type {Target[]} */ const targets = urls.map((url) => { if (url.startsWith("datajson+")) { - return { type: "data.json", url: url.slice("datajson+".length) }; + return { type: "datajson", url: url.slice("datajson+".length) }; } else if (url.startsWith("ckan+")) { return { type: "ckan", url: url.slice("ckan+".length) }; - } else return { type: "data.json", url }; + } else return { type: "datajson", url }; }); for (const target of targets) downloadFromData(target).catch((error) => - console.error(`${target} FALLĂ“ CON`, error) + console.error(`${target.type}+${target.url} FALLĂ“ CON`, error) ); /** @@ -53,7 +53,7 @@ async function downloadFromData(target) { let json; if (target.type === "ckan") { json = await generateDataJsonFromCkan(target.url); - } else if (target.type === "data.json") { + } else if (target.type === "datajson") { const jsonRes = await fetch(target.url); json = await jsonRes.json(); }