From eeedbb47a2e7a37ab6be27b217cb8a189c946a03 Mon Sep 17 00:00:00 2001 From: Bipul Date: Tue, 1 Sep 2020 21:25:10 +0530 Subject: [PATCH] Revert "LOC-1636 Detect Alpine linux and download specific binary" --- lib/Local.js | 3 +-- lib/LocalBinary.js | 39 ++++++++++------------------------ package-lock.json | 2 +- test/local.js | 53 +--------------------------------------------- 4 files changed, 14 insertions(+), 83 deletions(-) diff --git a/lib/Local.js b/lib/Local.js index 75af73e..9c0ed97 100644 --- a/lib/Local.js +++ b/lib/Local.js @@ -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(){ @@ -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); diff --git a/lib/LocalBinary.js b/lib/LocalBinary.js index c56c674..1fdc25b 100644 --- a/lib/LocalBinary.js +++ b/lib/LocalBinary.js @@ -3,7 +3,6 @@ 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'); @@ -11,33 +10,17 @@ 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; diff --git a/package-lock.json b/package-lock.json index 5c3c912..858387a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "browserstack-local", - "version": "1.4.6", + "version": "1.4.3", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/test/local.js b/test/local.js index c050ef4..79af54a 100644 --- a/test/local.js +++ b/test/local.js @@ -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(); }); @@ -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;