Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
quarto-dev
GitHub Repository: quarto-dev/quarto-cli
Path: blob/main/package/src/util/github.ts
6450 views
1
/*
2
* github.ts
3
*
4
* Copyright (C) 2020-2022 Posit Software, PBC
5
*
6
*/
7
import { join } from "../../../src/deno_ral/path.ts";
8
9
export interface GithubRelease {
10
version: string;
11
filename: string;
12
repo: string;
13
}
14
15
export async function download(
16
release: GithubRelease,
17
dir: string,
18
) {
19
const url =
20
`https://github.com/${release.repo}/releases/download/${release.version}/${release.filename}"`;
21
22
const response = await fetch(url);
23
const blob = await response.blob();
24
25
const bytes = await blob.arrayBuffer();
26
const data = new Uint8Array(bytes);
27
28
Deno.writeFileSync(join(dir, release.filename), data);
29
}
30
31