-
Notifications
You must be signed in to change notification settings - Fork 0
/
tasks.cjs
57 lines (45 loc) · 1.01 KB
/
tasks.cjs
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
const pkg = require("./package.json");
const fs = require("node:fs");
const path = require("node:path");
const archMap = {
ia32: "386",
x64: "amd64_v1",
arm64: "arm64",
};
const actions = {
install,
uninstall,
};
try {
main();
} catch (err) {
console.error(err);
process.exit(1);
}
function install() {
const { goBinary } = pkg;
const src = path.join(
".",
"dist",
`konk_${process.platform}_${archMap[process.arch]}`,
goBinary.name,
);
const dest = path.join(goBinary.path, goBinary.name);
fs.mkdirSync(goBinary.path, { recursive: true });
fs.copyFileSync(src, dest);
}
function uninstall() {
const dest = path.join(goBinary.path, goBinary.name);
console.log("Removing konk binaries from", dest);
fs.unlinkSync(dest);
}
function main() {
const command = process.argv[2];
const action = actions[command];
if (!action) {
console.error("Unknown command:", command);
console.error("Usage: node tasks.cjs [install|uninstall]");
process.exit(1);
}
action();
}