@@ -10,6 +10,7 @@ import Downloader from './helpers/downloader';
1010import Logger from '../services/logger' ;
1111import Installer from './helpers/installer' ;
1212import VirtualBoxInstall from './virtualbox' ;
13+ import Util from './helpers/util' ;
1314
1415
1516class CygwinInstall extends InstallableItem {
@@ -28,11 +29,32 @@ class CygwinInstall extends InstallableItem {
2829 this . addOption ( 'install' , this . version , '' , true ) ;
2930 }
3031
32+ isSkipped ( ) {
33+ let t = this . selectedOption === 'detected' ;
34+ return t ;
35+ }
36+
3137 static key ( ) {
3238 return 'cygwin' ;
3339 }
3440
35- checkForExistingInstall ( ) {
41+ detectExistingInstall ( cb = new function ( ) { } ) {
42+ let cygwinPackageRegex = / c y g w i n \s * ( \d + \. \d + \. \d + ) / ,
43+ opensshPackageReqex = / o p e n s s h \s * ( \d + \. \d + ) / ,
44+ rsyncPackageRegex = / r s y n c \s * ( \d + \. \d + \. \d + ) / ;
45+ Util . executeCommand ( 'cygcheck -c cygwin openssh rsync' ) . then ( ( out ) => {
46+ let cygwinVersion = cygwinPackageRegex . exec ( out ) [ 1 ] ;
47+ let opensshVersion = opensshPackageReqex . exec ( out ) [ 1 ] ;
48+ let rsyncVersion = rsyncPackageRegex . exec ( out ) [ 1 ] ;
49+ this . addOption ( 'detected' , '' , '' , true ) ;
50+ this . option [ 'detected' ] . version = cygwinVersion ;
51+ this . selectedOption = 'detected' ;
52+ cb ( ) ;
53+ } ) . catch ( ( error ) => {
54+ this . addOption ( 'install' , this . version , path . join ( this . installerDataSvc . installRoot , 'cygwin' ) , true ) ;
55+ this . addOption ( 'different' , '' , '' , false ) ;
56+ cb ( error ) ;
57+ } ) ;
3658 }
3759
3860 downloadInstaller ( progress , success , failure ) {
0 commit comments