-
Notifications
You must be signed in to change notification settings - Fork 9
/
make.js
94 lines (82 loc) · 2.1 KB
/
make.js
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
import fs from "fs-extra";
import yaargs from "yargs";
import { hideBin } from "yargs/helpers";
const yargs = yaargs(hideBin(process.argv));
let DEST_DIR = "/";
let PREFIX = "/usr";
let INSTALL_ZSH_COMPLETION = true;
let INSTALL_BASH_COMPLETION = true;
let ARCH = process.arch;
yargs.parserConfiguration({
"short-option-groups": true,
"camel-case-expansion": false,
"dot-notation": true,
"parse-numbers": true,
"parse-positional-numbers": true,
"boolean-negation": true,
"deep-merge-config": false,
});
let argv = yargs
.scriptName("make")
.usage("$0 [args]")
.command("install", "Install nody-greeter")
.command("build", "Build nody-greeter")
.command("uninstall", "Uninstall nody-greeter")
.option("DEST_DIR", {
type: "string",
describe: "Where to install nody-greeter",
default: DEST_DIR,
})
.option("PREFIX", {
type: "string",
describe: "Prefix to install at",
default: PREFIX,
})
.option("ARCH", {
type: "string",
describe: "Architecture to build for",
default: ARCH,
})
.option("INSTALL_ZSH_COMPLETION", {
type: "boolean",
describe: "Wheter to install zsh completion",
default: INSTALL_ZSH_COMPLETION,
})
.option("INSTALL_BASH_COMPLETION", {
type: "boolean",
describe: "Wheter to install bash completion",
default: INSTALL_BASH_COMPLETION,
})
.help("h")
.alias("h", "help")
.version(false).argv;
PREFIX = argv.PREFIX;
DEST_DIR = argv.DEST_DIR;
ARCH = argv.ARCH;
async function do_install() {
const { build } = await import("./build.js");
const { install } = await import("./install.js");
if (!fs.pathExistsSync("./build/unpacked")) {
console.log("nody-greeter is not built");
await build();
}
await install();
}
async function do_build() {
const { build } = await import("./build.js");
build();
}
async function do_uninstall() {
const { uninstall } = await import("./uninstall.js");
uninstall();
}
if (argv._[0] == "install") {
do_install();
} else if (argv._[0] == "build") {
do_build();
} else if (argv._[0] == "uninstall") {
do_uninstall();
} else {
yargs.showHelp();
process.exit(1);
}