1
1
var childProcess = require ( 'child_process' ) ,
2
+ os = require ( 'os' ) ,
2
3
fs = require ( 'fs' ) ,
3
4
path = require ( 'path' ) ,
4
5
running = require ( 'is-running' ) ,
@@ -7,11 +8,17 @@ var childProcess = require('child_process'),
7
8
psTree = require ( 'ps-tree' ) ;
8
9
9
10
function Local ( ) {
11
+ this . sanitizePath = function ( rawPath ) {
12
+ var doubleQuoteIfRequired = this . windows && ! rawPath . match ( / " [ ^ " ] + " / ) ? '"' : '' ;
13
+ return doubleQuoteIfRequired + rawPath + doubleQuoteIfRequired ;
14
+ } ;
15
+
16
+ this . windows = os . platform ( ) . 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 | w i n 3 2 / i) ;
10
17
this . pid = undefined ;
11
18
this . isProcessRunning = false ;
12
19
this . retriesLeft = 5 ;
13
20
this . key = process . env . BROWSERSTACK_ACCESS_KEY ;
14
- this . logfile = path . join ( process . cwd ( ) , 'local.log' ) ;
21
+ this . logfile = this . sanitizePath ( path . join ( process . cwd ( ) , 'local.log' ) ) ;
15
22
this . opcode = 'start' ;
16
23
this . exitCallback ;
17
24
@@ -124,7 +131,7 @@ function Local(){
124
131
case 'folder' :
125
132
if ( value ) {
126
133
this . folderFlag = '-f' ;
127
- this . folderPath = value ;
134
+ this . folderPath = this . sanitizePath ( value ) ;
128
135
}
129
136
break ;
130
137
@@ -157,7 +164,7 @@ function Local(){
157
164
case 'logfile' :
158
165
case 'logFile' :
159
166
if ( value )
160
- this . logfile = value ;
167
+ this . logfile = this . sanitizePath ( value ) ;
161
168
break ;
162
169
163
170
case 'parallelRuns' :
@@ -167,7 +174,7 @@ function Local(){
167
174
168
175
case 'binarypath' :
169
176
if ( value )
170
- this . binaryPath = value ;
177
+ this . binaryPath = this . sanitizePath ( value ) ;
171
178
break ;
172
179
173
180
default :
0 commit comments