forked from acquitelol/rosiecord
-
Notifications
You must be signed in to change notification settings - Fork 3
/
constants.js
62 lines (62 loc) · 1.89 KB
/
constants.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
import { exec } from "child_process";
class Shell {
static async write(text) {
return await new Promise((resolve) => {
process.stdout.write(text.toString());
resolve(text.toString());
});
}
static async run(command = 'ls', after) {
return await new Promise((resolve) => {
exec(command, (stderr, stdout) => {
after === null || after === void 0 ? void 0 : after(stderr, stdout);
resolve(stdout);
});
});
}
static async runSilently(command = 'ls', after = (stderr, stdout) => { }) {
return await new Promise((resolve) => {
const finalCommand = command.includes('&')
? command.split('&')[0] + '> /dev/null ' + "&" + command.split('&')[1]
: command + ' > /dev/null';
exec(finalCommand, (stderr, stdout) => {
after(stderr, stdout);
resolve(stdout);
});
});
}
}
;
class Colors {
constructor() {
this.RED = '\x1b[91m';
this.GREEN = '\x1b[92m';
this.BLUE = '\x1b[94m';
this.PINK = '\x1b[95m';
this.CYAN = '\x1b[96m';
this.ENDC = '\x1b[0m';
}
}
;
class Divider extends Colors {
constructor(length) {
super();
this.length = length;
}
async logDivider() {
await Shell.write(`${this.PINK}-${this.CYAN}~`.repeat(this.length) + '\n' + this.ENDC);
}
}
;
class States extends Colors {
constructor() {
super();
this.PENDING = `${this.PINK}[${this.CYAN}*${this.PINK}]${this.ENDC}`;
this.FAILURE = `${this.PINK}[${this.CYAN}-${this.PINK}]${this.RED}`;
this.SUCCESS = `${this.PINK}[${this.CYAN}+${this.PINK}]${this.GREEN}`;
}
}
class Constants {
}
Constants.IPA_FETCH_LINK = process.argv[process.argv.length-1];
export { Shell, Colors, Divider, States, Constants };