-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathuninstall.js
44 lines (36 loc) · 1.07 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
#!/usr/bin/env node
const fs = require("fs");
const path = require("path");
const { exec } = require("child_process");
const { homedir } = require("os");
const cargoDir = path.join(homedir(), ".cargo");
// check if directory exists
if (fs.existsSync(cargoDir)) {
// console.log("Cargo found.");
} else {
const setCargo = 'PATH="/$HOME/.cargo/bin:${PATH}"';
console.log("Installing deps [cargo].");
exec(
`curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y && ${setCargo}`,
(error) => {
if (error) {
console.log(
"curl failed! Curl may not be installed on the OS. View https://curl.se/download.html to install."
);
console.log(error);
}
}
);
}
const binp = path.join(cargoDir, "bin", "cmdo-gen");
if (fs.existsSync(binp)) {
console.log("Uninstalling cmdo-gen...");
exec(`cargo uninstall cmdo-gen`, (error, stdout, stderr) => {
console.log(stdout);
if (error || stderr) {
console.log(error || stderr);
}
});
} else {
console.log("cmdo-gen not found skipping!");
}