diff --git a/lib/Local.js b/lib/Local.js index 51e5b8c..9c0ed97 100644 --- a/lib/Local.js +++ b/lib/Local.js @@ -1,4 +1,5 @@ var childProcess = require('child_process'), + os = require('os'), fs = require('fs'), path = require('path'), running = require('is-running'), @@ -7,11 +8,17 @@ var childProcess = require('child_process'), psTree = require('ps-tree'); function Local(){ + this.sanitizePath = function(rawPath) { + var doubleQuoteIfRequired = this.windows && !rawPath.match(/"[^"]+"/) ? '"' : ''; + return doubleQuoteIfRequired + rawPath + doubleQuoteIfRequired; + }; + + this.windows = os.platform().match(/mswin|msys|mingw|cygwin|bccwin|wince|emc|win32/i); this.pid = undefined; this.isProcessRunning = false; this.retriesLeft = 5; this.key = process.env.BROWSERSTACK_ACCESS_KEY; - this.logfile = path.join(process.cwd(), 'local.log'); + this.logfile = this.sanitizePath(path.join(process.cwd(), 'local.log')); this.opcode = 'start'; this.exitCallback; @@ -124,7 +131,7 @@ function Local(){ case 'folder': if(value){ this.folderFlag = '-f'; - this.folderPath = value; + this.folderPath = this.sanitizePath(value); } break; @@ -157,7 +164,7 @@ function Local(){ case 'logfile': case 'logFile': if(value) - this.logfile = value; + this.logfile = this.sanitizePath(value); break; case 'parallelRuns': @@ -167,7 +174,7 @@ function Local(){ case 'binarypath': if(value) - this.binaryPath = value; + this.binaryPath = this.sanitizePath(value); break; default: