@belym.a.2105/sauce-tunnel
Advanced tools
Comparing version 2.5.2 to 3.0.0
80
index.js
/* npm */ | ||
var chalk = require('chalk'); | ||
var request = require('request').defaults({jar:false}); | ||
var split = require('split'); | ||
const chalk = require('chalk'); | ||
const split = require('split'); | ||
const axios = require('axios'); | ||
/* core */ | ||
var util = require('util'); | ||
var os = require('os'); | ||
var path = require('path'); | ||
var proc = require('child_process'); | ||
var EventEmitter = require('events').EventEmitter; | ||
var binaries = { | ||
const util = require('util'); | ||
const os = require('os'); | ||
const path = require('path'); | ||
const proc = require('child_process'); | ||
const EventEmitter = require('events').EventEmitter; | ||
const binaries = { | ||
'darwin': 'sc', | ||
@@ -19,2 +21,17 @@ 'linux': 'sc', | ||
async function request ({ method, url }, callback) { | ||
try { | ||
const res = await axios({ | ||
method, | ||
url, | ||
responseType: 'json', | ||
}) | ||
callback(null, res); | ||
} catch (e) { | ||
callback(e); | ||
} | ||
} | ||
module.exports = SauceTunnel; | ||
@@ -36,5 +53,4 @@ | ||
SauceTunnel.prototype.openTunnel = function(callback) { | ||
var me = this; | ||
// win32, darwin or linux | ||
var platform = os.platform(); | ||
let platform = os.platform(); | ||
@@ -44,7 +60,7 @@ // Special case: 32bit linux? | ||
var executable = binaries[platform]; | ||
const executable = binaries[platform]; | ||
if (!executable) { | ||
throw new Error(platform + ' platform is not supported'); | ||
} | ||
var args = ['-u', this.user, '-k', this.key]; | ||
let args = ['-u', this.user, '-k', this.key]; | ||
if (this.identifier) { | ||
@@ -56,3 +72,3 @@ args.push("-i", this.identifier); | ||
} | ||
var cmd = path.join(__dirname, 'vendor', platform, 'bin/', executable); | ||
const cmd = path.join(__dirname, 'vendor', platform, 'bin/', executable); | ||
@@ -62,8 +78,8 @@ this.proc = proc.spawn(cmd, args); | ||
this.proc.stdout.pipe(split()).on('data', function(data) { | ||
this.proc.stdout.pipe(split()).on('data', (data) => { | ||
if (!data.match(/^\[-u,/g)) { | ||
me.emit('verbose:debug', data); | ||
this.emit('verbose:debug', data); | ||
} | ||
if (data.match(/Sauce Connect is up, you may start your tests/)) { | ||
me.emit('verbose:ok', '=> Sauce Labs Tunnel established'); | ||
this.emit('verbose:ok', '=> Sauce Labs Tunnel established'); | ||
if (!callback.called) { | ||
@@ -74,15 +90,14 @@ callback.called = true; | ||
} | ||
var match = data.match(/Tunnel ID\: ([a-z0-9]{32})/); | ||
const match = data.match(/Tunnel ID\: ([a-z0-9]{32})/); | ||
if (match) { | ||
me.id = match[1]; | ||
this.id = match[1]; | ||
} | ||
}); | ||
this.proc.stderr.pipe(split()).on('data', function(data) { | ||
me.emit('log:error', data); | ||
this.proc.stderr.pipe(split()).on('data', (data) => { | ||
this.emit('log:error', data); | ||
}); | ||
var self = this; | ||
this.proc.on('exit', function(code) { | ||
me.emit('verbose:ok', 'Sauce Labs Tunnel disconnected ', code); | ||
this.proc.on('exit', (code) => { | ||
this.emit('verbose:ok', 'Sauce Labs Tunnel disconnected ', code); | ||
if (!callback.called) { | ||
@@ -97,5 +112,5 @@ callback.called = true; | ||
request({ | ||
method: 'GET', | ||
url: this.baseUrl + '/tunnels', | ||
json: true | ||
}, function(err, resp, body) { | ||
}, (err, resp, body) => { | ||
callback(body); | ||
@@ -114,4 +129,3 @@ }); | ||
url: this.baseUrl + "/tunnels/" + this.id, | ||
json: true | ||
}, function (err, resp, body) { | ||
}, (err, resp, body) => { | ||
if (!err && resp.statusCode === 200) { | ||
@@ -124,7 +138,6 @@ this.emit('verbose:debug', 'Tunnel Closed'); | ||
callback(err); | ||
}.bind(this)); | ||
}); | ||
}; | ||
SauceTunnel.prototype.start = function(callback) { | ||
var me = this; | ||
if (!this.tunneled) { | ||
@@ -140,4 +153,3 @@ return callback(true); | ||
SauceTunnel.prototype.stop = function (callback) { | ||
var self = this, | ||
callbackArg; | ||
let callbackArg; | ||
@@ -148,3 +160,3 @@ this.proc.on('exit', function () { | ||
this.killTunnel(function (err) { | ||
this.killTunnel((err) => { | ||
// When deleting the tunnel via the REST API succeeds, then Sauce Connect exits automatically. | ||
@@ -154,3 +166,3 @@ // Otherwise kill the process. Don't care with the tunnel, it will time out. | ||
callbackArg = err; | ||
self.proc.kill(); | ||
this.proc.kill(); | ||
} | ||
@@ -157,0 +169,0 @@ }); |
{ | ||
"name": "@belym.a.2105/sauce-tunnel", | ||
"version": "2.5.2", | ||
"version": "3.0.0", | ||
"description": "A wrapper around the Sauce Labs tunnel jar", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "node ./test/sanity" | ||
"test": "node ./test/sanity", | ||
"publish-please": "publish-please", | ||
"prepublishOnly": "publish-please guard" | ||
}, | ||
@@ -23,6 +25,9 @@ "repository": { | ||
"dependencies": { | ||
"axios": "^1.4.0", | ||
"chalk": "^1.1.3", | ||
"request": "^2.72.0", | ||
"split": "^1.0.0" | ||
}, | ||
"devDependencies": { | ||
"publish-please": "^5.5.2" | ||
} | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
101924651
24
180
1
6
+ Addedaxios@^1.4.0
+ Addedaxios@1.7.9(transitive)
+ Addedfollow-redirects@1.15.9(transitive)
+ Addedform-data@4.0.1(transitive)
+ Addedproxy-from-env@1.1.0(transitive)
- Removedrequest@^2.72.0
- Removedajv@6.12.6(transitive)
- Removedasn1@0.2.6(transitive)
- Removedassert-plus@1.0.0(transitive)
- Removedaws-sign2@0.7.0(transitive)
- Removedaws4@1.13.2(transitive)
- Removedbcrypt-pbkdf@1.0.2(transitive)
- Removedcaseless@0.12.0(transitive)
- Removedcore-util-is@1.0.2(transitive)
- Removeddashdash@1.14.1(transitive)
- Removedecc-jsbn@0.1.2(transitive)
- Removedextend@3.0.2(transitive)
- Removedextsprintf@1.3.0(transitive)
- Removedfast-deep-equal@3.1.3(transitive)
- Removedfast-json-stable-stringify@2.1.0(transitive)
- Removedforever-agent@0.6.1(transitive)
- Removedform-data@2.3.3(transitive)
- Removedgetpass@0.1.7(transitive)
- Removedhar-schema@2.0.0(transitive)
- Removedhar-validator@5.1.5(transitive)
- Removedhttp-signature@1.2.0(transitive)
- Removedis-typedarray@1.0.0(transitive)
- Removedisstream@0.1.2(transitive)
- Removedjsbn@0.1.1(transitive)
- Removedjson-schema@0.4.0(transitive)
- Removedjson-schema-traverse@0.4.1(transitive)
- Removedjson-stringify-safe@5.0.1(transitive)
- Removedjsprim@1.4.2(transitive)
- Removedoauth-sign@0.9.0(transitive)
- Removedperformance-now@2.1.0(transitive)
- Removedpsl@1.15.0(transitive)
- Removedpunycode@2.3.1(transitive)
- Removedqs@6.5.3(transitive)
- Removedrequest@2.88.2(transitive)
- Removedsafe-buffer@5.2.1(transitive)
- Removedsafer-buffer@2.1.2(transitive)
- Removedsshpk@1.18.0(transitive)
- Removedtough-cookie@2.5.0(transitive)
- Removedtunnel-agent@0.6.0(transitive)
- Removedtweetnacl@0.14.5(transitive)
- Removeduri-js@4.4.1(transitive)
- Removeduuid@3.4.0(transitive)
- Removedverror@1.10.0(transitive)