@@ -9,31 +9,25 @@ function LocalBinary(){
99 this . is64bits = process . arch == 'x64' ;
1010
1111 if ( this . hostOS . match ( / d a r w i n | m a c o s / i) ) {
12- this . httpPath = 'https://s3.amazonaws.com/browserStack/browserstack- local/BrowserStackLocal-darwin-x64' ;
12+ this . httpPath = 'https://s3.amazonaws.com/bs-automate-prod/ local/BrowserStackLocal-darwin-x64' ;
1313 } else if ( this . hostOS . match ( / m s w i n | m s y s | m i n g w | c y g w i n | b c c w i n | w i n c e | e m c / i) ) {
1414 this . windows = true ;
15- this . httpPath = 'https://s3.amazonaws.com/browserStack/browserstack- local/BrowserStackLocal.exe' ;
15+ this . httpPath = 'https://s3.amazonaws.com/bs-automate-prod/ local/BrowserStackLocal-win32 .exe' ;
1616 } else {
1717 if ( this . is64bits )
18- this . httpPath = 'https://s3.amazonaws.com/browserStack/browserstack- local/BrowserStackLocal-linux-x64' ;
18+ this . httpPath = 'https://s3.amazonaws.com/bs-automate-prod/ local/BrowserStackLocal-linux-x64' ;
1919 else
20- this . httpPath = 'https://s3.amazonaws.com/browserStack/browserstack- local/BrowserStackLocal-linux-ia32' ;
20+ this . httpPath = 'https://s3.amazonaws.com/bs-automate-prod/ local/BrowserStackLocal-linux-ia32' ;
2121 }
2222
23- this . orderedPaths = [
24- path . join ( os . homedir ( ) , '.browserstack' ) ,
25- process . cwd ( ) ,
26- os . tmpdir ( )
27- ] ;
28-
2923 this . download = function ( destParentDir , callback ) {
3024 if ( ! this . checkPath ( destParentDir ) )
31- fs . mkdirSync ( path ) ;
25+ fs . mkdirSync ( destParentDir ) ;
3226
33- var binaryPath = destParentDir + './ BrowserStackLocal';
27+ var binaryPath = path . join ( destParentDir , ' BrowserStackLocal') ;
3428 var file = fs . createWriteStream ( binaryPath ) ;
3529
36- https . get ( this . http_path , function ( response ) {
30+ https . get ( this . httpPath , function ( response ) {
3731 response . on ( 'end' , function ( ) {
3832 fs . chmod ( binaryPath , '0755' , function ( ) {
3933 callback ( binaryPath ) ;
@@ -59,7 +53,15 @@ function LocalBinary(){
5953 fs . accessSync ( path , mode ) ;
6054 return true ;
6155 } catch ( e ) {
62- return false ;
56+ if ( typeof fs . accessSync !== 'undefined' ) return false ;
57+
58+ // node v0.10
59+ try {
60+ fs . statSync ( path ) ;
61+ return true ;
62+ } catch ( e ) {
63+ return false ;
64+ }
6365 }
6466 } ;
6567
@@ -82,6 +84,34 @@ function LocalBinary(){
8284 return false ;
8385 }
8486 } ;
87+
88+ this . homedir = function ( ) {
89+ if ( typeof os . homedir === 'function' ) return os . homedir ( ) ;
90+
91+ var env = process . env ;
92+ var home = env . HOME ;
93+ var user = env . LOGNAME || env . USER || env . LNAME || env . USERNAME ;
94+
95+ if ( process . platform === 'win32' ) {
96+ return env . USERPROFILE || env . HOMEDRIVE + env . HOMEPATH || home || null ;
97+ }
98+
99+ if ( process . platform === 'darwin' ) {
100+ return home || ( user ? '/Users/' + user : null ) ;
101+ }
102+
103+ if ( process . platform === 'linux' ) {
104+ return home || ( process . getuid ( ) === 0 ? '/root' : ( user ? '/home/' + user : null ) ) ;
105+ }
106+
107+ return home || null ;
108+ } ;
109+
110+ this . orderedPaths = [
111+ path . join ( this . homedir ( ) , '.browserstack' ) ,
112+ process . cwd ( ) ,
113+ os . tmpdir ( )
114+ ] ;
85115}
86116
87117module . exports = LocalBinary ;
0 commit comments