Passed
Push — main ( 6c7a2f...4e8e13 )
by Bjarn
03:31 queued 01:55
created

Tool.uninstall   A

Complexity

Conditions 2

Size

Total Lines 12
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 11
dl 0
loc 12
rs 9.85
c 0
b 0
f 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