1
1
"use strict" ;
2
+ var compareVersions_1 = require ( '../../../utils/compareVersions' ) ;
3
+ var system_1 = require ( '../../../utils/system' ) ;
2
4
var atom_plugin_command_line_1 = require ( 'atom-plugin-command-line' ) ;
3
5
var versions = {
4
6
node : '4.0.0' ,
5
7
atom : '1.8.0' ,
6
8
npm : '3.0.0'
7
9
} ;
8
- function matchVersions ( v ) {
9
- return v . match ( / ( [ 0 - 9 ] + ) \. ( [ 0 - 9 ] + ) / ) ;
10
- }
11
- function isAboveVersion ( a , b ) {
12
- if ( a === b ) {
13
- return true ;
14
- }
15
- var a_components = a . split ( '.' ) ;
16
- var b_components = b . split ( '.' ) ;
17
- var len = Math . min ( a_components . length , b_components . length ) ;
18
- for ( var i = 0 ; i < len ; i ++ ) {
19
- var first = parseInt ( a_components [ i ] , 10 ) ;
20
- var second = parseInt ( b_components [ i ] , 10 ) ;
21
- if ( first > second ) {
22
- return true ;
23
- }
24
- if ( first < second ) {
25
- return false ;
26
- }
27
- }
28
- if ( a_components . length > b_components . length ) {
29
- return true ;
30
- }
31
- if ( a_components . length < b_components . length ) {
32
- return false ;
33
- }
34
- return true ;
35
- }
36
10
function minVersion ( command ) {
37
11
var minVersion = versions [ command ] ;
38
12
return new Promise ( function ( resolve , reject ) {
39
13
var minOrLater = atom_plugin_command_line_1 . default ( command , '-v' )
40
- . then ( function ( res ) { return isAboveVersion ( res , minVersion ) ; } ) ;
14
+ . then ( function ( res ) { return compareVersions_1 . isAboveVersion ( res , minVersion ) ; } ) ;
41
15
if ( ! minOrLater ) {
42
16
resolve ( false ) ;
43
17
}
@@ -51,7 +25,7 @@ function atomMinVersion() {
51
25
return new Promise ( function ( resolve , reject ) {
52
26
var minOrLater = atom_plugin_command_line_1 . default ( 'atom' , '-v' ) . then ( function ( res ) {
53
27
var match = res . match ( / A t o m \s + : \s + ( [ 0 - 9 ] \. [ 0 - 9 ] \. [ 0 - 9 ] ) / ) ;
54
- if ( match && match [ 1 ] && isAboveVersion ( match [ 1 ] , versions . atom ) ) {
28
+ if ( match && match [ 1 ] && compareVersions_1 . isAboveVersion ( match [ 1 ] , versions . atom ) ) {
55
29
resolve ( true ) ;
56
30
}
57
31
else {
@@ -61,8 +35,8 @@ function atomMinVersion() {
61
35
} ) ;
62
36
}
63
37
exports . atomMinVersion = atomMinVersion ;
64
- function requiresXCode ( ) {
65
- if ( ! navigator . platform . match ( / M a c / ) ) {
38
+ function hasOrDoesNotRequireXCode ( ) {
39
+ if ( ! system_1 . isMac ) {
66
40
return true ;
67
41
}
68
42
return atom_plugin_command_line_1 . default ( 'xcode-select' , '-v' ) . then ( function ( res ) {
@@ -72,4 +46,4 @@ function requiresXCode() {
72
46
return false ;
73
47
} ) ;
74
48
}
75
- exports . requiresXCode = requiresXCode ;
49
+ exports . hasOrDoesNotRequireXCode = hasOrDoesNotRequireXCode ;
0 commit comments