@@ -65,57 +65,31 @@ function LocalBinary(){
65
65
var destBinaryName = ( this . windows ) ? 'BrowserStackLocal.exe' : 'BrowserStackLocal' ;
66
66
var binaryPath = path . join ( destParentDir , destBinaryName ) ;
67
67
68
- var options = url . parse ( this . httpPath ) ;
69
- if ( conf . proxyHost && conf . proxyPort ) {
70
- options . agent = new HttpsProxyAgent ( {
71
- host : conf . proxyHost ,
72
- port : conf . proxyPort
73
- } ) ;
74
- }
75
-
76
- const osPlatform = os . platform ( ) ;
77
- const osVersion = parseInt ( os . release ( ) ) ;
78
-
79
68
let cmd , opts ;
80
-
81
- if ( osPlatform . includes ( 'win' ) && osVersion < 10 ) {
82
- cmd = 'wget' ;
83
- opts = [ ] ;
84
- if ( conf . proxyHost && conf . proxyPort ) {
85
- opts . push ( '-e' , `https_proxy=${ conf . proxyHost } :${ conf . proxyPort } ` , '--no-check-certificate' ) ;
86
- }
87
- opts . push ( '-O' , binaryPath , options . href ) ;
88
- } else {
89
- cmd = 'curl' ;
90
- opts = [ '-o' , binaryPath , options . href ] ;
91
-
92
- if ( conf . proxyHost && conf . proxyPort ) {
93
- opts . push ( '--proxy' , `${ conf . proxyHost } :${ conf . proxyPort } ` ) ;
94
- }
69
+ cmd = 'node' ;
70
+ opts = [ path . join ( __dirname , 'download.js' ) , binaryPath , this . httpPath ]
71
+ if ( conf . proxyHost && conf . proxyPort ) {
72
+ opts . push ( conf . proxyHost , conf . proxyPort ) ;
95
73
}
96
74
97
75
try {
98
76
const obj = childProcess . spawnSync ( cmd , opts ) ;
99
77
let output ;
100
78
if ( obj . stdout . length > 0 ) {
101
- output = Buffer . from ( JSON . parse ( JSON . stringify ( obj . stderr ) ) . data ) . toString ( ) ;
102
- } else if ( obj . stderr . length > 0 ) {
103
- output = Buffer . from ( JSON . parse ( JSON . stringify ( obj . stderr ) ) . data ) . toString ( ) ;
104
- }
105
- if ( output . includes ( 'failed' ) ) {
106
- console . log ( 'failed to download' ) ;
107
- return that . retryBinaryDownload ( conf , destParentDir , null , retries , binaryPath ) ;
108
- } else {
109
79
if ( fs . existsSync ( binaryPath ) ) {
110
80
fs . chmodSync ( binaryPath , '0755' ) ;
111
81
return binaryPath ;
112
82
} else {
113
83
console . log ( 'failed to download' ) ;
114
84
return that . retryBinaryDownload ( conf , destParentDir , null , retries , binaryPath ) ;
115
85
}
86
+ } else if ( obj . stderr . length > 0 ) {
87
+ output = Buffer . from ( JSON . parse ( JSON . stringify ( obj . stderr ) ) . data ) . toString ( ) ;
88
+ console . error ( output )
89
+ return that . retryBinaryDownload ( conf , destParentDir , null , retries , binaryPath ) ;
116
90
}
117
91
} catch ( err ) {
118
- console . log ( 'Download failed with error' , err ) ;
92
+ console . error ( 'Download failed with error' , err ) ;
119
93
return that . retryBinaryDownload ( conf , destParentDir , null , retries , binaryPath ) ;
120
94
}
121
95
} ;
0 commit comments