diff --git a/index.js b/index.js index 50ef001..737e941 100644 --- a/index.js +++ b/index.js @@ -1,15 +1,13 @@ // Import Node.js Dependencies +import * as fs from "node:fs/promises"; +import * as path from "node:path"; import { createWriteStream, createReadStream } from "node:fs"; -import fs from "node:fs/promises"; -import path from "node:path"; import { createGunzip } from "node:zlib"; import { pipeline } from "node:stream/promises"; // Import Third-party Dependencies import tar from "tar-fs"; import httpie from "@myunisoft/httpie"; -import * as dotenv from "dotenv"; -dotenv.config(); // CONSTANTS const kGithubURL = new URL("https://github.com/"); @@ -37,14 +35,15 @@ export async function download(repository, options = Object.create(null)) { const repositoryURL = new URL(`${organization}/${repo}/archive/${branch}.tar.gz`, kGithubURL); const location = path.join(dest, `${repo}-${branch}.tar.gz`); - await httpie.stream("GET", repositoryURL, { + const writableCallback = httpie.stream("GET", repositoryURL, { headers: { "User-Agent": "NodeSecure", "Accept-Encoding": "gzip, deflate", Authorization: typeof token === "string" ? `token ${token}` : GITHUB_TOKEN }, maxRedirections: 1 - })(createWriteStream(location)); + }); + await writableCallback(() => createWriteStream(location)); return { location, diff --git a/package.json b/package.json index e845eed..38b370a 100644 --- a/package.json +++ b/package.json @@ -30,11 +30,11 @@ }, "homepage": "https://github.com/NodeSecure/github#readme", "dependencies": { - "@myunisoft/httpie": "^1.10.0", - "tar-fs": "^2.1.1" + "@myunisoft/httpie": "^4.0.1", + "tar-fs": "^3.0.5" }, "devDependencies": { - "@nodesecure/eslint-config": "^1.5.0", + "@nodesecure/eslint-config": "^1.9.0", "@slimio/is": "^2.0.0", "c8": "^9.1.0", "dotenv": "^16.0.2",