@@ -9,31 +9,25 @@ function LocalBinary(){
9
9
this . is64bits = process . arch == 'x64' ;
10
10
11
11
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' ;
13
13
} 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) ) {
14
14
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' ;
16
16
} else {
17
17
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' ;
19
19
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' ;
21
21
}
22
22
23
- this . orderedPaths = [
24
- path . join ( os . homedir ( ) , '.browserstack' ) ,
25
- process . cwd ( ) ,
26
- os . tmpdir ( )
27
- ] ;
28
-
29
23
this . download = function ( destParentDir , callback ) {
30
24
if ( ! this . checkPath ( destParentDir ) )
31
- fs . mkdirSync ( path ) ;
25
+ fs . mkdirSync ( destParentDir ) ;
32
26
33
- var binaryPath = destParentDir + './ BrowserStackLocal';
27
+ var binaryPath = path . join ( destParentDir , ' BrowserStackLocal') ;
34
28
var file = fs . createWriteStream ( binaryPath ) ;
35
29
36
- https . get ( this . http_path , function ( response ) {
30
+ https . get ( this . httpPath , function ( response ) {
37
31
response . on ( 'end' , function ( ) {
38
32
fs . chmod ( binaryPath , '0755' , function ( ) {
39
33
callback ( binaryPath ) ;
@@ -59,7 +53,15 @@ function LocalBinary(){
59
53
fs . accessSync ( path , mode ) ;
60
54
return true ;
61
55
} 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
+ }
63
65
}
64
66
} ;
65
67
@@ -82,6 +84,34 @@ function LocalBinary(){
82
84
return false ;
83
85
}
84
86
} ;
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
+ ] ;
85
115
}
86
116
87
117
module . exports = LocalBinary ;
0 commit comments