Skip to content

Commit

Permalink
refactor: Rewrite file downloader
Browse files Browse the repository at this point in the history
  • Loading branch information
d3xter666 committed Apr 9, 2024
1 parent 4050c62 commit 1d5ca6c
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion scripts/metadataProvider/createPseudoModulesInfo.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {pipeline} from "node:stream/promises";
import https from "node:https";
import yauzl from "yauzl-promise";
import path from "node:path";
import MetadataProvider from "./MetadataProvider.js";
Expand All @@ -21,7 +22,12 @@ async function fetchAndExtractAPIJsons(url: string) {
const zipFileName: string = url.split("/").pop() ?? "";
const zipFile = path.resolve(RAW_API_JSON_FILES_FOLDER, zipFileName);
await mkdir(path.resolve(RAW_API_JSON_FILES_FOLDER), {recursive: true});
await pipeline(response.body, createWriteStream(zipFile));

await new Promise((resolve) => {
https.get(url, (res) => {
resolve(pipeline(res, createWriteStream(zipFile)));
});
});

const zip = await yauzl.open(zipFile);
try {
Expand Down

0 comments on commit 1d5ca6c

Please sign in to comment.