Skip to content

Commit d9505b7

Browse files
committed
handle windows os?
1 parent 9a860ea commit d9505b7

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

lib/local.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,23 @@
11
var exec = require('child_process').exec,
22
fs = require('fs'),
33
http = require('http'),
4-
localBinary = __dirname + '/BrowserStackLocal',
4+
windows = (process.platform.match(/win/) != null),
5+
localBinary = __dirname + (windows ? '/BrowserStackTunnel.jar' : '/BrowserStackLocal'),
56
utils = require('./utils'),
67
config = require('./config');
78

89
var Tunnel = function Tunnel (key, port, uniqueIdentifier, callback, err) {
910
var that = {};
1011

1112
function tunnelLauncher () {
12-
var tunnelCommand = localBinary + ' ';
13+
var tunnelCommand = (windows ? 'java -jar ' : '') + localBinary + ' ';
1314
if (config.debug)
1415
tunnelCommand += ' -v ';
1516
tunnelCommand += key + ' ';
1617
tunnelCommand += 'localhost' + ',';
1718
tunnelCommand += port.toString() + ',';
1819
tunnelCommand += '0';
19-
tunnelCommand += (typeof uniqueIdentifier === 'undefined')? ' -force -onlyAutomate' : ' -uniqueIdentifier ' + uniqueIdentifier;
20+
tunnelCommand += (typeof uniqueIdentifier === 'undefined')? ' -force -onlyAutomate' : ' -tunnelIdentifier ' + uniqueIdentifier;
2021

2122
if (typeof callback !== 'function') {
2223
callback = function () {};
@@ -70,7 +71,7 @@ var Tunnel = function Tunnel (key, port, uniqueIdentifier, callback, err) {
7071

7172
var file = fs.createWriteStream(localBinary);
7273
var request = http.get(
73-
("http://s3.amazonaws.com/browserStack/browserstack-local/BrowserStackLocal-" + process.platform + "-" + process.arch),
74+
(windows ? "http://www.browserstack.com/BrowserStackTunnel.jar" : ("http://s3.amazonaws.com/browserStack/browserstack-local/BrowserStackLocal-" + process.platform + "-" + process.arch)),
7475
function(response) {
7576
response.pipe(file);
7677

0 commit comments

Comments
 (0)