Skip to content

Commit c98889b

Browse files
committed
switch to binary
1 parent b40923a commit c98889b

File tree

3 files changed

+19
-16
lines changed

3 files changed

+19
-16
lines changed

bin/runner.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ var BrowserStack = require('browserstack'),
55
utils = require('../lib/utils');
66
Server = require('../lib/server').Server;
77
config = require('../lib/config');
8-
Tunnel = require('../lib/tunnel').Tunnel;
8+
Tunnel = require('../lib/local').Tunnel;
99

1010
var serverPort = 8888;
1111
var tunnel;

lib/tunnel.js renamed to lib/local.js

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,33 @@
11
var exec = require('child_process').exec,
22
fs = require('fs'),
33
http = require('http'),
4-
tunnelJar = __dirname + '/BrowserStackTunnel.jar',
4+
localBinary = __dirname + '/BrowserStackLocal',
55
utils = require('./utils'),
66
config = require('./config');
77

8-
var Tunnel = function Tunnel (key, port, tunnelIdentifier, callback, err) {
8+
var Tunnel = function Tunnel (key, port, uniqueIdentifier, callback, err) {
99
var that = {};
1010

1111
function tunnelLauncher () {
12-
var tunnelCommand = 'java -jar ' + tunnelJar + ' ';
12+
var tunnelCommand = localBinary + ' ';
1313
if (config.debug)
1414
tunnelCommand += ' -v ';
1515
tunnelCommand += key + ' ';
1616
tunnelCommand += 'localhost' + ',';
1717
tunnelCommand += port.toString() + ',';
1818
tunnelCommand += '0';
19-
tunnelCommand += (typeof tunnelIdentifier === 'undefined')? ' -force -onlyAutomate' : ' -tunnelIdentifier ' + tunnelIdentifier;
19+
tunnelCommand += (typeof uniqueIdentifier === 'undefined')? ' -force -onlyAutomate' : ' -uniqueIdentifier ' + uniqueIdentifier;
2020

2121
if (typeof callback !== 'function') {
2222
callback = function () {};
2323
}
2424

25-
console.log("Launching tunnel");
25+
console.log("[%s] Launching tunnel", new Date());
2626
var subProcess = exec(tunnelCommand, function (error, stdout, stderr) {
2727
console.log(stderr);
28+
console.log(error);
2829
if (stdout.indexOf('Error') >= 0) {
29-
console.log("Tunnel launching failed");
30+
console.log("[%s] Tunnel launching failed", new Date());
3031
console.log(stdout);
3132
process.exit(1);
3233
}
@@ -38,8 +39,7 @@ var Tunnel = function Tunnel (key, port, tunnelIdentifier, callback, err) {
3839

3940
setTimeout(function () {
4041
if (!running) {
41-
utils.alertBrowserStack("Tunnel launch timeout",
42-
'Stdout:\n' + data);
42+
utils.alertBrowserStack("Tunnel launch timeout", 'Stdout:\n' + data);
4343
}
4444
}, 30 * 1000);
4545

@@ -52,27 +52,30 @@ var Tunnel = function Tunnel (key, port, tunnelIdentifier, callback, err) {
5252

5353
if (data.indexOf(runMatcher) >= 0) {
5454
running = true;
55-
console.log("Tunnel launched");
55+
console.log("[%s] Tunnel launched", new Date());
5656
callback();
5757
}
5858
});
5959

6060
that.process = subProcess;
6161
}
6262

63-
fs.exists(tunnelJar, function (exists) {
63+
fs.exists(localBinary, function (exists) {
6464
if (exists) {
65-
fs.unlinkSync(tunnelJar);
65+
fs.unlinkSync(localBinary);
66+
// tunnelLauncher();
67+
// return;
6668
}
67-
console.log('Downloading tunnel jar to `%s`', tunnelJar);
69+
console.log('Downloading BrowserStack Local to `%s`', localBinary);
6870

69-
var file = fs.createWriteStream(tunnelJar);
71+
var file = fs.createWriteStream(localBinary);
7072
var request = http.get(
71-
"http://www.browserstack.com/BrowserStackTunnel.jar",
73+
("http://s3.amazonaws.com/browserStack/browserstack-local/BrowserStackLocal-" + process.platform + "-" + process.arch),
7274
function(response) {
7375
response.pipe(file);
7476

7577
response.on('end', function () {
78+
fs.chmodSync(localBinary, 0700);
7679
tunnelLauncher();
7780
});
7881
}

lib/utils.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ var alertBrowserStack = function alertBrowserStack (subject, content, params, fn
3535
var urlObject = url.parse(endpoint);
3636

3737
var context = config.alert_context || "Runner alert";
38-
console.log("[%s] %s", context, subject);
38+
console.log("[%s] [%s] %s", new Date(), context, subject);
3939

4040
if (typeof fn !== 'function') {
4141
if (typeof params === 'function') {

0 commit comments

Comments
 (0)