@@ -6,10 +6,22 @@ const versions = {
6
6
npm : '3.0.0'
7
7
} ;
8
8
9
- function matchVersions ( v : string ) : string [ ] {
9
+ /**
10
+ * extracts versions intro array from a string
11
+ * "0.1.0" -> ['0', '1', '0']
12
+ * or returns null
13
+ * @param {string } v
14
+ */
15
+ function matchVersions ( v : string ) : string [ ] | null {
10
16
return v . match ( / ( [ 0 - 9 ] + ) \. ( [ 0 - 9 ] + ) / ) ;
11
17
}
12
18
19
+ /**
20
+ * checks that a version is >= b version
21
+ * @param {string } a
22
+ * @param {string } b
23
+ * @returns boolean
24
+ */
13
25
function isAboveVersion ( a : string , b : string ) : boolean {
14
26
if ( a === b ) { return true ; }
15
27
const a_components = a . split ( '.' ) ;
@@ -26,7 +38,14 @@ function isAboveVersion(a: string, b: string): boolean {
26
38
return true ;
27
39
}
28
40
29
- function minVersion ( command : string , minVersion : string ) : Promise < boolean > {
41
+ /**
42
+ * calls command line to check that system version is above requirement
43
+ * @param {string } command
44
+ * @param {string } minVersion
45
+ * @returns Promise
46
+ */
47
+ export function minVersion ( command : string ) : Promise < boolean > {
48
+ const minVersion = versions [ command ] ;
30
49
return new Promise ( ( resolve , reject ) => {
31
50
let minOrLater : Promise < boolean > = commandLine ( command , '-v' )
32
51
. then ( ( res : string ) => isAboveVersion ( res , minVersion ) ) ;
@@ -38,6 +57,10 @@ function minVersion(command: string, minVersion: string): Promise<boolean> {
38
57
} ) ;
39
58
}
40
59
60
+ /**
61
+ * checks that the version of atom is above a minimum version
62
+ * @returns Promise
63
+ */
41
64
export function atomMinVersion ( ) : Promise < boolean > {
42
65
return new Promise ( ( resolve , reject ) => {
43
66
let minOrLater = commandLine ( 'atom' , '-v' ) . then ( ( res : string ) => {
@@ -51,14 +74,6 @@ export function atomMinVersion(): Promise<boolean> {
51
74
} ) ;
52
75
}
53
76
54
- export function npmMinVersion ( ) : Promise < boolean > {
55
- return minVersion ( 'npm' , versions . npm ) ;
56
- }
57
-
58
- export function nodeMinVersion ( ) : Promise < boolean > {
59
- return minVersion ( 'node' , versions . node ) ;
60
- }
61
-
62
77
/**
63
78
* checks if is a mac
64
79
* checks if xcode is installed
0 commit comments