https://github.com/oscarotero/dbin
Deno library to download binary files from GitHub releases detecting the correct platform.
https://github.com/oscarotero/dbin
Last synced: 2 months ago
JSON representation
Deno library to download binary files from GitHub releases detecting the correct platform.
- Host: GitHub
- URL: https://github.com/oscarotero/dbin
- Owner: oscarotero
- License: mit
- Created: 2022-09-16T22:30:49.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2025-01-05T18:54:39.000Z (4 months ago)
- Last Synced: 2025-01-31T13:11:17.743Z (3 months ago)
- Language: TypeScript
- Homepage: https://deno.land/x/dbin/mod.ts
- Size: 12.7 KB
- Stars: 10
- Watchers: 3
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# Dbin
TypeScript library to download binary files from GitHub releases detecting the
correct platform. Example:```ts
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 `linux` and `x86_64` the target
is `x86_64-unknown-linux-musl`).
- Replace the variables `{version}` and `{target}` in the `pattern`url.
- Download the file.
- Decompress the `.tar.gz` file.
- Output to the `dest` file (`./_bin/pagefind` in the example). If the current
os is Windows, the `.exe` extension is appended to the file name.
- Change the output file permissions to `0o764` (except in Windows). Set the
`chmod` option for other value compatible with
[Deno.chmod](https://doc.deno.land/deno/stable/~/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: true` to download the file again.