11var childProcess = require ( 'child_process' ) ,
2+ os = require ( 'os' ) ,
23 fs = require ( 'fs' ) ,
34 path = require ( 'path' ) ,
45 running = require ( 'is-running' ) ,
@@ -7,11 +8,17 @@ var childProcess = require('child_process'),
78 psTree = require ( 'ps-tree' ) ;
89
910function 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) ;
1017 this . pid = undefined ;
1118 this . isProcessRunning = false ;
1219 this . retriesLeft = 5 ;
1320 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' ) ) ;
1522 this . opcode = 'start' ;
1623 this . exitCallback ;
1724
@@ -124,7 +131,7 @@ function Local(){
124131 case 'folder' :
125132 if ( value ) {
126133 this . folderFlag = '-f' ;
127- this . folderPath = value ;
134+ this . folderPath = this . sanitizePath ( value ) ;
128135 }
129136 break ;
130137
@@ -157,7 +164,7 @@ function Local(){
157164 case 'logfile' :
158165 case 'logFile' :
159166 if ( value )
160- this . logfile = value ;
167+ this . logfile = this . sanitizePath ( value ) ;
161168 break ;
162169
163170 case 'parallelRuns' :
@@ -167,7 +174,7 @@ function Local(){
167174
168175 case 'binarypath' :
169176 if ( value )
170- this . binaryPath = value ;
177+ this . binaryPath = this . sanitizePath ( value ) ;
171178 break ;
172179
173180 default :
0 commit comments