You've already forked careful-downloader
mirror of
https://github.com/jakejarvis/careful-downloader.git
synced 2026-06-17 14:05:28 -04:00
BREAKING: allow hashes provided as a URL to a text file or a string
(closes #1)
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
import stream from "stream";
|
||||
import { promisify } from "util";
|
||||
import fs from "fs-extra";
|
||||
import got from "got";
|
||||
|
||||
import debug from "./debug.js";
|
||||
|
||||
// Download any file to any destination. Returns a promise.
|
||||
export default async (url, dest) => {
|
||||
debug(`Downloading '${url}' to '${dest}'`);
|
||||
|
||||
// get remote file and write locally
|
||||
const pipeline = promisify(stream.pipeline);
|
||||
const download = pipeline(
|
||||
got.stream(url, { followRedirect: true }), // GitHub releases redirect to unpredictable URLs
|
||||
fs.createWriteStream(dest),
|
||||
);
|
||||
|
||||
return download;
|
||||
};
|
||||
Reference in New Issue
Block a user