Skip to content

Commit 5227eec

Browse files
committed
Merge pull request #1 from browserstack/travis
Travis configured
2 parents baf4a36 + e57c5e2 commit 5227eec

File tree

5 files changed

+56
-22
lines changed

5 files changed

+56
-22
lines changed

.travis.yml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1-
language: node
2-
nvm:
3-
- 0.10.33
1+
language: node_js
2+
node_js:
3+
- "4.3"
4+
- "4.0"
5+
- "0.12"
6+
- "0.10"
47

58
before_install:
69
- true && `base64 --decode <<< ZXhwb3J0IEJST1dTRVJTVEFDS19BQ0NFU1NfS0VZPUh5VmZydXJvb3dYb041eGhLZEs2Cg==`

lib/Local.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ function Local(){
1212
this.logfile = path.join(process.cwd(), 'local.log');
1313
this.exitCallback;
1414

15-
this.errorRegex = /\*\*\* Error\: [^\n]+/i;
15+
this.errorRegex = /\*\*\* Error\: [^\n]+?/i;
1616
this.doneRegex = /Press Ctrl-C to exit/i;
1717

1818
this.start = function(options, callback){

lib/LocalBinary.js

Lines changed: 44 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,31 +9,25 @@ function LocalBinary(){
99
this.is64bits = process.arch == 'x64';
1010

1111
if(this.hostOS.match(/darwin|mac os/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';
1313
} else if(this.hostOS.match(/mswin|msys|mingw|cygwin|bccwin|wince|emc/i)) {
1414
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';
1616
} else {
1717
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';
1919
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';
2121
}
2222

23-
this.orderedPaths = [
24-
path.join(os.homedir(), '.browserstack'),
25-
process.cwd(),
26-
os.tmpdir()
27-
];
28-
2923
this.download = function(destParentDir, callback){
3024
if(!this.checkPath(destParentDir))
31-
fs.mkdirSync(path);
25+
fs.mkdirSync(destParentDir);
3226

33-
var binaryPath = destParentDir + './BrowserStackLocal';
27+
var binaryPath = path.join(destParentDir, 'BrowserStackLocal');
3428
var file = fs.createWriteStream(binaryPath);
3529

36-
https.get(this.http_path, function (response) {
30+
https.get(this.httpPath, function (response) {
3731
response.on('end', function () {
3832
fs.chmod(binaryPath, '0755', function() {
3933
callback(binaryPath);
@@ -59,7 +53,15 @@ function LocalBinary(){
5953
fs.accessSync(path, mode);
6054
return true;
6155
} 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+
}
6365
}
6466
};
6567

@@ -82,6 +84,34 @@ function LocalBinary(){
8284
return false;
8385
}
8486
};
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+
];
85115
}
86116

87117
module.exports = LocalBinary;

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
"devDependencies": {
2121
"eslint": "1.10.3",
2222
"expect.js": "0.3.1",
23-
"mocha": "2.4.5"
23+
"mocha": "2.4.5",
24+
"mocks": "0.0.15"
2425
}
2526
}

test/local.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,15 @@ describe('Local', function () {
99
});
1010

1111
it('should have pid when running', function (done) {
12-
this.timeout(15000);
12+
this.timeout(600000);
1313
bsLocal.start({ key: process.env.BROWSERSTACK_ACCESS_KEY }, function(){
1414
expect(bsLocal.tunnel.pid).to.not.equal(0);
1515
done();
1616
});
1717
});
1818

1919
it('should return is running properly', function (done) {
20-
this.timeout(15000);
20+
this.timeout(60000);
2121
expect(bsLocal.isRunning()).to.not.equal(true);
2222
bsLocal.start({ key: process.env.BROWSERSTACK_ACCESS_KEY }, function(){
2323
expect(bsLocal.isRunning()).to.equal(true);
@@ -26,7 +26,7 @@ describe('Local', function () {
2626
});
2727

2828
it('should throw error on running multiple binary', function (done) {
29-
this.timeout(25000);
29+
this.timeout(60000);
3030
bsLocal.start({ key: process.env.BROWSERSTACK_ACCESS_KEY }, function(){
3131
bsLocal_2 = new browserstack.Local();
3232
try{

0 commit comments

Comments
 (0)