Deno library to download binary files from GitHub releases detecting the correct platform.
Repository
Current version released
a year ago
Dependencies
Versions
Dbin
TypeScript library to download binary files from GitHub releases detecting the correct platform. Example:
import dbin from "https://deno.land/x/dbin/mod.ts";
const binfile = await dbin({
pattern:
"https://github.com/CloudCannon/pagefind/releases/download/{version}/pagefind-{version}-{target}.tar.gz",
version: "v0.8.1",
targets: [
{ name: "x86_64-unknown-linux-musl", os: "linux", arch: "x86_64" },
{ name: "x86_64-apple-darwin", os: "darwin", arch: "x86_64" },
{ name: "x86_64-pc-windows-msvc", os: "windows", arch: "x86_64" },
],
dest: "./_bin/pagefind",
});This function does the following:
- Detects the current target (for example, for
linuxandx86_64the target isx86_64-unknown-linux-musl). - Replace the variables
{version}and{target}in thepatternurl. - Download the file.
- Decompress the
.tar.gzfile. - Output to the
destfile (./_bin/pagefindin the example). If the current os is Windows, the.exeextension is appended to the file name. - Change the output file permissions to
0o764(except in Windows). Set thechmodoption for other value compatible with Deno.chmod. - Returns the full path to the executable file.
- If the function is executed again, and the dest file exists, it does nothing.
Set
override: trueto download the file again.