Completed
Push — develop ( ce87b1...9599d4 )
by Bjarn
18s queued 11s
created

Expose   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 33
dl 0
loc 47
rs 10
c 0
b 0
f 0
wmc 5

3 Functions

Rating   Name   Duplication   Size   Complexity  
A isInstalled 0 3 1
A install 0 13 2
A uninstall 0 12 2
1
import execa from 'execa'
2
import Tool from './tool'
3
4
class Expose extends Tool {
5
    alias = 'expose'
6
    name = 'Beyondcode Expose'
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. Execute it by running ${this.alias}`)
14
            return false
15
        }
16
17
        console.log(`Installing ${this.name} using Composer...`)
18
19
        await execa('composer', ['global', 'require', 'beyondcode/expose'])
20
21
        console.log(`Successfully installed ${this.name}`)
22
23
        return true
24
    }
25
26
27
    /**
28
     * Uninstall the app.
29
     */
30
    uninstall = async (): Promise<boolean> => {
31
        if (!(await this.isInstalled())) {
32
            console.log(`${this.name} is not installed`)
33
        }
34
35
        console.log(`Uninstalling ${this.name} using Composer...`)
36
37
        await execa('composer', ['global', 'remove', 'beyondcode/expose'])
38
39
        console.log(`Successfully uninstalled ${this.name}`)
40
41
        return true
42
    }
43
44
    /**
45
     * Check if the app is already installed..
46
     */
47
    isInstalled = async (): Promise<boolean> => {
48
        const {stdout} = await execa('composer', ['global', 'show', '-i'])
49
        return stdout.includes('beyondcode/expose')
50
    }
51
}
52
53
export default Expose