Total Complexity | 5 |
Complexity/F | 1.67 |
Lines of Code | 48 |
Function Count | 3 |
Duplicated Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | import {client} from '../utils/os' |
||
2 | |||
3 | abstract class Tool { |
||
4 | |||
5 | abstract name: string |
||
6 | abstract alias: string |
||
7 | |||
8 | /** |
||
9 | * Install the app. |
||
10 | */ |
||
11 | install = async (): Promise<boolean> => { |
||
12 | if (await this.isInstalled()) { |
||
13 | console.log(`${this.name} already is installed`) |
||
14 | return false |
||
15 | } |
||
16 | |||
17 | console.log(`Installing ${this.name}...`) |
||
18 | await client().packageManager.install(this.alias, false) |
||
19 | return true |
||
20 | } |
||
21 | |||
22 | /** |
||
23 | * Uninstall the app. |
||
24 | */ |
||
25 | uninstall = async (): Promise<boolean> => { |
||
26 | if (!(await this.isInstalled())) { |
||
27 | console.log(`${this.name} is not installed`) |
||
28 | } |
||
29 | |||
30 | console.log(`Uninstalling ${this.name}...`) |
||
31 | |||
32 | await client().packageManager.uninstall(this.alias, false) |
||
33 | |||
34 | console.log(`Installed ${this.name}`) |
||
35 | |||
36 | return true |
||
37 | } |
||
38 | |||
39 | /** |
||
40 | * Check if the is already installed.. |
||
41 | */ |
||
42 | isInstalled = async (): Promise<boolean> => { |
||
43 | return client().packageManager.packageIsInstalled(this.alias) |
||
44 | } |
||
45 | |||
46 | } |
||
47 | |||
48 | export default Tool |