@@ -6,10 +6,22 @@ const versions = {
66npm :'3.0.0'
77} ;
88
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 {
1016return v . match ( / ( [ 0 - 9 ] + ) \. ( [ 0 - 9 ] + ) / ) ;
1117}
1218
19+ /**
20+ * checks that a version is >= b version
21+ *@param {string } a
22+ *@param {string } b
23+ *@returns boolean
24+ */
1325function isAboveVersion ( a :string , b :string ) :boolean {
1426if ( a === b ) { return true ; }
1527const a_components = a . split ( '.' ) ;
@@ -26,7 +38,14 @@ function isAboveVersion(a: string, b: string): boolean {
2638return true ;
2739}
2840
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 ] ;
3049return new Promise ( ( resolve , reject ) => {
3150let minOrLater :Promise < boolean > = commandLine ( command , '-v' )
3251. then ( ( res :string ) => isAboveVersion ( res , minVersion ) ) ;
@@ -38,6 +57,10 @@ function minVersion(command: string, minVersion: string): Promise<boolean> {
3857} ) ;
3958}
4059
60+ /**
61+ * checks that the version of atom is above a minimum version
62+ *@returns Promise
63+ */
4164export function atomMinVersion ( ) :Promise < boolean > {
4265return new Promise ( ( resolve , reject ) => {
4366let minOrLater = commandLine ( 'atom' , '-v' ) . then ( ( res :string ) => {
@@ -51,14 +74,6 @@ export function atomMinVersion(): Promise<boolean> {
5174} ) ;
5275}
5376
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-
6277/**
6378 * checks if is a mac
6479 * checks if xcode is installed