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