forked from tejacques/crosstab
-
Notifications
You must be signed in to change notification settings - Fork 0
/
sauceconnect.js
44 lines (38 loc) · 1.07 KB
/
sauceconnect.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
var fs = require('fs');
var envPath = './.env.js';
if (fs.existsSync(envPath)) {
console.log("Adding environment variables");
require(envPath);
}
var readLine = require ("readline");
if (process.platform === "win32"){
var rl = readLine.createInterface ({
input: process.stdin,
output: process.stdout
});
rl.on ("SIGINT", function (){
process.emit ("SIGINT");
});
}
console.log("Creating tunnel");
var SauceTunnel = require('sauce-tunnel');
var tunnel = new SauceTunnel(process.env.SAUCE_USERNAME, process.env.SAUCE_ACCESS_KEY);
function done() {
console.log("Closing tunnel");
tunnel.stop(function () {
console.log("Tunnel closed");
process.exit();
});
}
['SIGINT', 'SIGHUP', 'SIGQUIT', 'SIGABRT', 'SIGTERM'].forEach(function(signal) {
process.on(signal, done);
});
console.log("Starting tunnel");
tunnel.start(function(status) {
if (status) {
console.log("Tunnel started successfully");
} else {
console.log("Failed to start tunnel successfully");
process.exit(1);
}
});