forked from JezerM/nody-greeter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
uninstall.js
85 lines (73 loc) · 2.38 KB
/
uninstall.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
import fs from "fs-extra";
import path from "path";
import ora from "ora";
import yaargs from "yargs";
import { hideBin } from "yargs/helpers";
const yargs = yaargs(hideBin(process.argv));
let DEST_DIR = "/";
let PREFIX = "/usr";
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("install")
.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,
})
.help("h")
.alias("h", "help")
.version(false).argv;
PREFIX = argv.PREFIX;
DEST_DIR = argv.DEST_DIR;
// Some global variables
let nody_path = path.join(DEST_DIR, "opt/nody-greeter");
let bin_path = path.join(DEST_DIR, PREFIX, "bin");
let lightdm_path = path.join(DEST_DIR, "etc/lightdm");
let webg_path = path.join(DEST_DIR, PREFIX, "share/web-greeter");
let xgreeters_path = path.join(DEST_DIR, PREFIX, "share/xgreeters");
let applications_path = path.join(DEST_DIR, PREFIX, "share/applications");
let xdg_ldm_path = path.join(DEST_DIR, "etc/xdg/lightdm/lightdm.conf.d/");
let uninstall_paths = [
//path.join(lightdm_path, "web-greeter.yml"),
//path.join(webg_path, "themes/"),
path.join(xgreeters_path, "nody-greeter.desktop"),
path.join(applications_path, "nody-greeter.desktop"),
path.join(xdg_ldm_path, "90-greeter-wrapper.conf"),
path.join(lightdm_path, "Xgreeter"),
nody_path,
path.join(bin_path, "nody-greeter"),
];
export async function uninstall() {
console.log(`Uninstalling nody-greeter inside "${DEST_DIR}"...`);
let spinner = ora({ text: "Uninstalling...", spinner: "dots" });
spinner.start();
for (let i = 0; i < uninstall_paths.length; i++) {
let file = uninstall_paths[i];
spinner.text = "Uninstalling: " + file;
fs.rmSync(file, { force: true, recursive: true });
//await wait(500);
}
spinner.succeed("nody-greeter was uninstalled");
console.log("\x1b[92mSUCCESS!\x1b[0m");
console.log(
"Themes are not uninstalled. Remove them manually:",
`\n\t${webg_path}`
);
console.log(
"nody-greeter config was not uninstalled. Remove it manually:",
`\n\t${path.join(lightdm_path, "web-greeter.yml")}`
);
}