-
Notifications
You must be signed in to change notification settings - Fork 431
Expand file tree
/
Copy pathtypst-gather.ts
More file actions
57 lines (51 loc) · 2.02 KB
/
typst-gather.ts
File metadata and controls
57 lines (51 loc) · 2.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import { join, dirname } from "../../../../src/deno_ral/path.ts"
import { ensureDirSync, existsSync } from "../../../../src/deno_ral/fs.ts"
import { Configuration } from "../config.ts";
import { Dependency } from "./dependencies.ts";
import { which } from "../../../../src/core/path.ts";
import { unTar } from "../../util/tar.ts";
export function typstGather(version: string): Dependency {
const typstGatherRelease = (filename: string) => {
return {
filename,
url: `https://github.com/quarto-dev/typst-gather/releases/download/v${version}/${filename}`,
configure: async (config: Configuration, path: string) => {
const file = config.os === "windows" ? "typst-gather.exe" : "typst-gather";
const vendor = Deno.env.get("QUARTO_VENDOR_BINARIES");
if (vendor === undefined || vendor === "true") {
const dir = dirname(path);
const targetDir = join(dir, config.arch);
ensureDirSync(targetDir);
// expand
await unTar(path);
// move the binary and cleanup
const extractedPath = join(dir, file);
Deno.renameSync(extractedPath, join(targetDir, file));
} else {
// verify that the binary is on PATH, but otherwise don't do anything
if (which(file) === undefined) {
throw new Error(
`${file} is not on PATH. Please install it and add it to PATH.`,
);
}
}
}
}
}
return {
name: "typst-gather",
bucket: "typst-gather",
version,
architectureDependencies: {
"x86_64": {
"windows": typstGatherRelease("typst-gather-x86_64-pc-windows-msvc.zip"),
"linux": typstGatherRelease("typst-gather-x86_64-unknown-linux-gnu.tar.gz"),
"darwin": typstGatherRelease("typst-gather-x86_64-apple-darwin.tar.gz"),
},
"aarch64": {
"linux": typstGatherRelease("typst-gather-aarch64-unknown-linux-gnu.tar.gz"),
"darwin": typstGatherRelease("typst-gather-aarch64-apple-darwin.tar.gz"),
}
}
}
}