Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@belym.a.2105/sauce-tunnel

Package Overview
Dependencies
Maintainers
8
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@belym.a.2105/sauce-tunnel - npm Package Compare versions

Comparing version 2.5.2 to 3.0.0

.github/labels.yml

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"
}
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc