mirror of
https://github.com/jakejarvis/careful-downloader.git
synced 2025-04-26 03:05:23 -04:00
67 lines
1.7 KiB
TypeScript
67 lines
1.7 KiB
TypeScript
export interface Options {
|
|
/**
|
|
* Filename of the download, helpful if the one provided by the server doesn't
|
|
* match the name listed in the checksum file.
|
|
*
|
|
* @default Extracted from the download URL.
|
|
*/
|
|
readonly filename?: string;
|
|
|
|
/**
|
|
* Use decompress to extract the final download to the destination directory.
|
|
*
|
|
* @default false
|
|
*/
|
|
readonly extract?: boolean;
|
|
|
|
/**
|
|
* Path to temporary directory for unverified and/or unextracted downloads.
|
|
* Automatically generated if not set (recommended).
|
|
*
|
|
* @default `tempy.directory()`
|
|
*/
|
|
readonly tempDir?: string;
|
|
|
|
/**
|
|
* Full path or directory name relative to module to store the validated
|
|
* download.
|
|
*
|
|
* @default "./downloads"
|
|
*/
|
|
readonly destDir?: string;
|
|
|
|
/**
|
|
* Delete any existing files in the destination directory before downloading.
|
|
*
|
|
* @default false
|
|
*/
|
|
readonly cleanDestDir?: boolean;
|
|
|
|
/**
|
|
* The algorithm used by the checksum file. Available options are dependent on
|
|
* the version of OpenSSL on the platform. Examples are 'SHA1', 'SHA256',
|
|
* 'SHA512', 'MD5', etc.
|
|
*
|
|
* On recent releases of OpenSSL, `openssl list -digest-algorithms` will
|
|
* display the available digest algorithms:
|
|
*
|
|
* https://nodejs.org/dist/latest-v4.x/docs/api/crypto.html#crypto_crypto_createhash_algorithm
|
|
*
|
|
* @default "sha256"
|
|
*/
|
|
readonly algorithm?: string;
|
|
|
|
/**
|
|
* Tell the file stream to read the download as a binary, UTF-8 text file,
|
|
* base64, etc.
|
|
*
|
|
* @default "binary"
|
|
*/
|
|
readonly encoding?: BufferEncoding;
|
|
}
|
|
|
|
/**
|
|
* Download a file and validate it with its corresponding checksum file.
|
|
*/
|
|
export default function downloadAndCheck(downloadUrl: string, checksumUrl: string, options: Options): Promise<string>;
|