11"use strict" ;
2+ var compareVersions_1 = require ( '../../../utils/compareVersions' ) ;
3+ var system_1 = require ( '../../../utils/system' ) ;
24var atom_plugin_command_line_1 = require ( 'atom-plugin-command-line' ) ;
35var versions = {
46 node : '4.0.0' ,
57 atom : '1.8.0' ,
68 npm : '3.0.0'
79} ;
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- }
3610function minVersion ( command ) {
3711 var minVersion = versions [ command ] ;
3812 return new Promise ( function ( resolve , reject ) {
3913 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 ) ; } ) ;
4115 if ( ! minOrLater ) {
4216 resolve ( false ) ;
4317 }
@@ -51,7 +25,7 @@ function atomMinVersion() {
5125 return new Promise ( function ( resolve , reject ) {
5226 var minOrLater = atom_plugin_command_line_1 . default ( 'atom' , '-v' ) . then ( function ( res ) {
5327 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 ) ) {
5529 resolve ( true ) ;
5630 }
5731 else {
@@ -61,8 +35,8 @@ function atomMinVersion() {
6135 } ) ;
6236}
6337exports . atomMinVersion = atomMinVersion ;
64- function requiresXCode ( ) {
65- if ( ! navigator . platform . match ( / M a c / ) ) {
38+ function hasOrDoesNotRequireXCode ( ) {
39+ if ( ! system_1 . isMac ) {
6640 return true ;
6741 }
6842 return atom_plugin_command_line_1 . default ( 'xcode-select' , '-v' ) . then ( function ( res ) {
@@ -72,4 +46,4 @@ function requiresXCode() {
7246 return false ;
7347 } ) ;
7448}
75- exports . requiresXCode = requiresXCode ;
49+ exports . hasOrDoesNotRequireXCode = hasOrDoesNotRequireXCode ;
0 commit comments