Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions lib/Local.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ var childProcess = require('child_process'),
running = require('is-running'),
LocalBinary = require('./LocalBinary'),
LocalError = require('./LocalError'),
version = require('../package.json').version,
psTree = require('ps-tree');

function Local(){
Expand Down Expand Up @@ -206,7 +205,7 @@ function Local(){
};

this.getBinaryArgs = function(){
var args = ['--daemon', this.opcode, '--log-file', this.logfile, '--source', `nodejs-${version}`];
var args = ['--daemon', this.opcode, '--log-file', this.logfile];
if(this.key) {
args.push('--key');
args.push(this.key);
Expand Down
39 changes: 11 additions & 28 deletions lib/LocalBinary.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,41 +3,24 @@ var https = require('https'),
fs = require('fs'),
path = require('path'),
os = require('os'),
childProcess = require('child_process'),
HttpsProxyAgent = require('https-proxy-agent'),
LocalError = require('./LocalError');

function LocalBinary(){
this.hostOS = process.platform;
this.is64bits = process.arch == 'x64';

this.getDownloadPath = function () {
if(this.hostOS.match(/darwin|mac os/i)){
return 'https://bstack-local-prod.s3.amazonaws.com/BrowserStackLocal-darwin-x64';
} else if(this.hostOS.match(/mswin|msys|mingw|cygwin|bccwin|wince|emc|win32/i)) {
this.windows = true;
return 'https://bstack-local-prod.s3.amazonaws.com/BrowserStackLocal.exe';
} else {
if(this.isAlpine()) {
return 'https://bstack-local-prod.s3.amazonaws.com/BrowserStackLocal-alpine';
} else {
if(this.is64bits)
return 'https://bstack-local-prod.s3.amazonaws.com/BrowserStackLocal-linux-x64';
else
return 'https://bstack-local-prod.s3.amazonaws.com/BrowserStackLocal-linux-ia32';
}
}
};

this.httpPath = this.getDownloadPath();

this.isAlpine = function() {
try {
return childProcess.execSync('grep -w "NAME" /etc/os-release').includes('Alpine');
} catch(e) {
return false;
}
};
if(this.hostOS.match(/darwin|mac os/i)){
this.httpPath = 'https://s3.amazonaws.com/bstack-local-prod/BrowserStackLocal-darwin-x64';
} else if(this.hostOS.match(/mswin|msys|mingw|cygwin|bccwin|wince|emc|win32/i)) {
this.windows = true;
this.httpPath = 'https://s3.amazonaws.com/bstack-local-prod/BrowserStackLocal.exe';
} else {
if(this.is64bits)
this.httpPath = 'https://s3.amazonaws.com/bstack-local-prod/BrowserStackLocal-linux-x64';
else
this.httpPath = 'https://s3.amazonaws.com/bstack-local-prod/BrowserStackLocal-linux-ia32';
}

this.retryBinaryDownload = function(conf, destParentDir, callback, retries, binaryPath) {
var that = this;
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

53 changes: 1 addition & 52 deletions test/local.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ describe('Local', function () {
var tempLogPath = path.join(process.cwd(), 'log2.log');

bsLocal_2.start({ 'key': process.env.BROWSERSTACK_ACCESS_KEY, 'logfile': tempLogPath }, function(error){
expect(error.toString().trim()).to.equal('LocalError: Either another browserstack local client is running on your machine or some server is listening on port 45690');
expect(error.toString().trim()).to.equal('LocalError: Either another browserstack local client is running on your machine or some server is listening on port 45691');
fs.unlinkSync(tempLogPath);
done();
});
Expand Down Expand Up @@ -312,57 +312,6 @@ describe('LocalBinary', function () {
});
});

describe('Download Path', function() {
var sandBox;
var localBinary;

beforeEach(function() {
sandBox = sinon.sandbox.create();
localBinary = new LocalBinary();
});

it('should return download path of darwin binary', function() {
var osNames = ['darwin', 'mac os'];
osNames.forEach(function(os) {
sandBox.stub(localBinary, 'hostOS', os);
expect(localBinary.getDownloadPath()).to.equal('https://bstack-local-prod.s3.amazonaws.com/BrowserStackLocal-darwin-x64');
});
});

it('should return download path of exe binary', function() {
var osNames = ['mswin', 'msys', 'mingw', 'cygwin', 'bccwin', 'wince', 'emc', 'win32'];
osNames.forEach(function(os) {
sandBox.stub(localBinary, 'hostOS', os);
expect(localBinary.getDownloadPath()).to.equal('https://bstack-local-prod.s3.amazonaws.com/BrowserStackLocal.exe');
});
});

it('should return download path of linux 64 arch binary', function() {
sandBox.stub(localBinary, 'hostOS', 'linux');
sandBox.stub(localBinary, 'is64bits', true);
localBinary.isAlpine = sandBox.stub(localBinary, 'isAlpine').returns(false);
expect(localBinary.getDownloadPath()).to.equal('https://bstack-local-prod.s3.amazonaws.com/BrowserStackLocal-linux-x64');
});

it('should return download path of linux 32 arch binary', function() {
sandBox.stub(localBinary, 'hostOS', 'linux');
sandBox.stub(localBinary, 'is64bits', false);
localBinary.isAlpine = sandBox.stub(localBinary, 'isAlpine').returns(false);
expect(localBinary.getDownloadPath()).to.equal('https://bstack-local-prod.s3.amazonaws.com/BrowserStackLocal-linux-ia32');
});

it('should return download path of alpine linux binary', function() {
sandBox.stub(localBinary, 'hostOS', 'linux');
localBinary.isAlpine = sandBox.stub(localBinary, 'isAlpine').returns(true);
expect(localBinary.getDownloadPath()).to.equal('https://bstack-local-prod.s3.amazonaws.com/BrowserStackLocal-alpine');
});

afterEach(function(done) {
sandBox.restore();
done();
});
});

describe('Download', function() {
var proxy;
var proxyPort;
Expand Down