From 7a369a0ee3ffdc85e086c38ae3a022123e1f7ef1 Mon Sep 17 00:00:00 2001 From: Vibhaj Rajan Date: Tue, 1 Mar 2016 19:03:04 +0530 Subject: [PATCH 01/12] updated s3 paths --- .travis.yml | 9 ++++++--- lib/LocalBinary.js | 8 ++++---- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/.travis.yml b/.travis.yml index bea397a..088dad1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,9 @@ -language: node -nvm: - - 0.10.33 +language: node_js +node_js: + - "4.3" + - "4.0" + - "0.12" + - "0.10" before_install: - true && `base64 --decode <<< ZXhwb3J0IEJST1dTRVJTVEFDS19BQ0NFU1NfS0VZPUh5VmZydXJvb3dYb041eGhLZEs2Cg==` diff --git a/lib/LocalBinary.js b/lib/LocalBinary.js index f174d01..550c071 100644 --- a/lib/LocalBinary.js +++ b/lib/LocalBinary.js @@ -9,15 +9,15 @@ function LocalBinary(){ this.is64bits = process.arch == 'x64'; if(this.hostOS.match(/darwin|mac os/i)){ - this.httpPath = 'https://s3.amazonaws.com/browserStack/browserstack-local/BrowserStackLocal-darwin-x64'; + this.httpPath = "https://s3.amazonaws.com/bs-automate-prod/local/BrowserStackLocal-darwin-x64"; } else if(this.hostOS.match(/mswin|msys|mingw|cygwin|bccwin|wince|emc/i)) { this.windows = true; - this.httpPath = 'https://s3.amazonaws.com/browserStack/browserstack-local/BrowserStackLocal.exe'; + this.httpPath = "https://s3.amazonaws.com/bs-automate-prod/local/BrowserStackLocal-win32.exe"; } else { if(this.is64bits) - this.httpPath = 'https://s3.amazonaws.com/browserStack/browserstack-local/BrowserStackLocal-linux-x64'; + this.httpPath = "https://s3.amazonaws.com/bs-automate-prod/local/BrowserStackLocal-linux-x64"; else - this.httpPath = 'https://s3.amazonaws.com/browserStack/browserstack-local/BrowserStackLocal-linux-ia32'; + this.httpPath = "https://s3.amazonaws.com/bs-automate-prod/local/BrowserStackLocal-linux-ia32"; } this.orderedPaths = [ From 295049d371240c497784d7ebb1e5b4b0e91af086 Mon Sep 17 00:00:00 2001 From: Vibhaj Rajan Date: Tue, 1 Mar 2016 19:08:02 +0530 Subject: [PATCH 02/12] updated lint --- lib/LocalBinary.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/LocalBinary.js b/lib/LocalBinary.js index 550c071..8de417b 100644 --- a/lib/LocalBinary.js +++ b/lib/LocalBinary.js @@ -9,15 +9,15 @@ function LocalBinary(){ this.is64bits = process.arch == 'x64'; if(this.hostOS.match(/darwin|mac os/i)){ - this.httpPath = "https://s3.amazonaws.com/bs-automate-prod/local/BrowserStackLocal-darwin-x64"; + this.httpPath = 'https://s3.amazonaws.com/bs-automate-prod/local/BrowserStackLocal-darwin-x64'; } else if(this.hostOS.match(/mswin|msys|mingw|cygwin|bccwin|wince|emc/i)) { this.windows = true; - this.httpPath = "https://s3.amazonaws.com/bs-automate-prod/local/BrowserStackLocal-win32.exe"; + this.httpPath = 'https://s3.amazonaws.com/bs-automate-prod/local/BrowserStackLocal-win32.exe'; } else { if(this.is64bits) - this.httpPath = "https://s3.amazonaws.com/bs-automate-prod/local/BrowserStackLocal-linux-x64"; + this.httpPath = 'https://s3.amazonaws.com/bs-automate-prod/local/BrowserStackLocal-linux-x64'; else - this.httpPath = "https://s3.amazonaws.com/bs-automate-prod/local/BrowserStackLocal-linux-ia32"; + this.httpPath = 'https://s3.amazonaws.com/bs-automate-prod/local/BrowserStackLocal-linux-ia32'; } this.orderedPaths = [ From 2fe916446de4e1b1ddc9bafe62a4c53e6197ca33 Mon Sep 17 00:00:00 2001 From: Vibhaj Rajan Date: Tue, 1 Mar 2016 19:11:45 +0530 Subject: [PATCH 03/12] updated package.json --- package.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index c6228ac..dbd6546 100644 --- a/package.json +++ b/package.json @@ -20,6 +20,7 @@ "devDependencies": { "eslint": "1.10.3", "expect.js": "0.3.1", - "mocha": "2.4.5" + "mocha": "2.4.5", + "mocks": "0.0.15" } } From 9522aa007ab8ae758fd1979fc3db3ee5aeaf30c0 Mon Sep 17 00:00:00 2001 From: Vibhaj Rajan Date: Tue, 1 Mar 2016 19:14:42 +0530 Subject: [PATCH 04/12] path issue --- lib/LocalBinary.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/LocalBinary.js b/lib/LocalBinary.js index 8de417b..d0d5cf4 100644 --- a/lib/LocalBinary.js +++ b/lib/LocalBinary.js @@ -30,7 +30,7 @@ function LocalBinary(){ if(!this.checkPath(destParentDir)) fs.mkdirSync(path); - var binaryPath = destParentDir + './BrowserStackLocal'; + var binaryPath = path.join(destParentDir, 'BrowserStackLocal'); var file = fs.createWriteStream(binaryPath); https.get(this.http_path, function (response) { From 934520d819bc90c1d992f15cba64e9eb7b635757 Mon Sep 17 00:00:00 2001 From: Vibhaj Rajan Date: Tue, 1 Mar 2016 19:23:07 +0530 Subject: [PATCH 05/12] fixes bugs --- lib/LocalBinary.js | 2 +- test/local.js | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/LocalBinary.js b/lib/LocalBinary.js index d0d5cf4..af61381 100644 --- a/lib/LocalBinary.js +++ b/lib/LocalBinary.js @@ -33,7 +33,7 @@ function LocalBinary(){ var binaryPath = path.join(destParentDir, 'BrowserStackLocal'); var file = fs.createWriteStream(binaryPath); - https.get(this.http_path, function (response) { + https.get(this.httpPath, function (response) { response.on('end', function () { fs.chmod(binaryPath, '0755', function() { callback(binaryPath); diff --git a/test/local.js b/test/local.js index 36b99ff..39f9b40 100644 --- a/test/local.js +++ b/test/local.js @@ -9,7 +9,7 @@ describe('Local', function () { }); it('should have pid when running', function (done) { - this.timeout(15000); + this.timeout(600000); bsLocal.start({ key: process.env.BROWSERSTACK_ACCESS_KEY }, function(){ expect(bsLocal.tunnel.pid).to.not.equal(0); done(); @@ -17,7 +17,7 @@ describe('Local', function () { }); it('should return is running properly', function (done) { - this.timeout(15000); + this.timeout(60000); expect(bsLocal.isRunning()).to.not.equal(true); bsLocal.start({ key: process.env.BROWSERSTACK_ACCESS_KEY }, function(){ expect(bsLocal.isRunning()).to.equal(true); @@ -26,7 +26,7 @@ describe('Local', function () { }); it('should throw error on running multiple binary', function (done) { - this.timeout(25000); + this.timeout(60000); bsLocal.start({ key: process.env.BROWSERSTACK_ACCESS_KEY }, function(){ bsLocal_2 = new browserstack.Local(); try{ From b7019a320e08f62a99f5d2cde667a82921412363 Mon Sep 17 00:00:00 2001 From: Vibhaj Rajan Date: Tue, 1 Mar 2016 19:27:41 +0530 Subject: [PATCH 06/12] added homedir polyfil --- lib/LocalBinary.js | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/lib/LocalBinary.js b/lib/LocalBinary.js index af61381..e2d8fcd 100644 --- a/lib/LocalBinary.js +++ b/lib/LocalBinary.js @@ -21,7 +21,7 @@ function LocalBinary(){ } this.orderedPaths = [ - path.join(os.homedir(), '.browserstack'), + path.join(this.homedir(), '.browserstack'), process.cwd(), os.tmpdir() ]; @@ -82,6 +82,28 @@ function LocalBinary(){ return false; } }; + + this.homedir = function() { + if(typeof os.homedir === 'function') return os.homedir(); + + var env = process.env; + var home = env.HOME; + var user = env.LOGNAME || env.USER || env.LNAME || env.USERNAME; + + if (process.platform === 'win32') { + return env.USERPROFILE || env.HOMEDRIVE + env.HOMEPATH || home || null; + } + + if (process.platform === 'darwin') { + return home || (user ? '/Users/' + user : null); + } + + if (process.platform === 'linux') { + return home || (process.getuid() === 0 ? '/root' : (user ? '/home/' + user : null)); + } + + return home || null; + } } module.exports = LocalBinary; From 3b745cd180ae903ac273f00d423bcb321b625d1b Mon Sep 17 00:00:00 2001 From: Vibhaj Rajan Date: Tue, 1 Mar 2016 19:33:10 +0530 Subject: [PATCH 07/12] fixes homedir issue --- lib/LocalBinary.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/LocalBinary.js b/lib/LocalBinary.js index e2d8fcd..131b9fa 100644 --- a/lib/LocalBinary.js +++ b/lib/LocalBinary.js @@ -20,12 +20,6 @@ function LocalBinary(){ this.httpPath = 'https://s3.amazonaws.com/bs-automate-prod/local/BrowserStackLocal-linux-ia32'; } - this.orderedPaths = [ - path.join(this.homedir(), '.browserstack'), - process.cwd(), - os.tmpdir() - ]; - this.download = function(destParentDir, callback){ if(!this.checkPath(destParentDir)) fs.mkdirSync(path); @@ -103,7 +97,13 @@ function LocalBinary(){ } return home || null; - } + }; + + this.orderedPaths = [ + path.join(this.homedir(), '.browserstack'), + process.cwd(), + os.tmpdir() + ]; } module.exports = LocalBinary; From b41cd14f061388c2670e3b36b637fa847d8d1e47 Mon Sep 17 00:00:00 2001 From: Vibhaj Rajan Date: Tue, 1 Mar 2016 19:38:47 +0530 Subject: [PATCH 08/12] updated regex for exception --- lib/Local.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Local.js b/lib/Local.js index 742d47f..6abd481 100644 --- a/lib/Local.js +++ b/lib/Local.js @@ -12,7 +12,7 @@ function Local(){ this.logfile = path.join(process.cwd(), 'local.log'); this.exitCallback; - this.errorRegex = /\*\*\* Error\: [^\n]+/i; + this.errorRegex = /\*\*\* Error\: [^\n]+?/i; this.doneRegex = /Press Ctrl-C to exit/i; this.start = function(options, callback){ From 85a7c9d11269c9e17f991018c48d759a6f09e76d Mon Sep 17 00:00:00 2001 From: Vibhaj Rajan Date: Tue, 1 Mar 2016 19:45:16 +0530 Subject: [PATCH 09/12] fixes mkdirSync --- lib/LocalBinary.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/LocalBinary.js b/lib/LocalBinary.js index 131b9fa..5671d98 100644 --- a/lib/LocalBinary.js +++ b/lib/LocalBinary.js @@ -22,7 +22,7 @@ function LocalBinary(){ this.download = function(destParentDir, callback){ if(!this.checkPath(destParentDir)) - fs.mkdirSync(path); + fs.mkdirSync(destParentDir); var binaryPath = path.join(destParentDir, 'BrowserStackLocal'); var file = fs.createWriteStream(binaryPath); From 9376c4f808d7447573052e48d6a56cc86bb09d7a Mon Sep 17 00:00:00 2001 From: Vibhaj Rajan Date: Tue, 1 Mar 2016 19:54:04 +0530 Subject: [PATCH 10/12] 10.33 --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 088dad1..5cfed16 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,7 +3,7 @@ node_js: - "4.3" - "4.0" - "0.12" - - "0.10" + - "0.10.33" before_install: - true && `base64 --decode <<< ZXhwb3J0IEJST1dTRVJTVEFDS19BQ0NFU1NfS0VZPUh5VmZydXJvb3dYb041eGhLZEs2Cg==` From 87c774ac469261ad8c50c3526b528c8f2d10a30d Mon Sep 17 00:00:00 2001 From: Vibhaj Rajan Date: Tue, 1 Mar 2016 20:13:01 +0530 Subject: [PATCH 11/12] accessSync issue node 0.10 --- lib/LocalBinary.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/LocalBinary.js b/lib/LocalBinary.js index 5671d98..83151d5 100644 --- a/lib/LocalBinary.js +++ b/lib/LocalBinary.js @@ -53,7 +53,15 @@ function LocalBinary(){ fs.accessSync(path, mode); return true; } catch(e){ - return false; + if(typeof fs.accessSync !== 'undefined') return false; + + // node v0.10 + try { + fs.statSync(path); + return true; + } catch (e){ + return false; + } } }; From e57c5e241407b422762d3c177ee19aaa20fdabc8 Mon Sep 17 00:00:00 2001 From: Vibhaj Rajan Date: Tue, 1 Mar 2016 20:13:11 +0530 Subject: [PATCH 12/12] accessSync issue node 0.10 --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 5cfed16..088dad1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,7 +3,7 @@ node_js: - "4.3" - "4.0" - "0.12" - - "0.10.33" + - "0.10" before_install: - true && `base64 --decode <<< ZXhwb3J0IEJST1dTRVJTVEFDS19BQ0NFU1NfS0VZPUh5VmZydXJvb3dYb041eGhLZEs2Cg==`