1
1
var exec = require ( 'child_process' ) . exec ,
2
2
fs = require ( 'fs' ) ,
3
3
http = require ( 'http' ) ,
4
- tunnelJar = '/tmp /BrowserStackTunnel.jar',
4
+ tunnelJar = __dirname + ' /BrowserStackTunnel.jar',
5
5
utils = require ( './utils' ) ,
6
6
config = require ( './config' ) ;
7
7
@@ -24,6 +24,7 @@ var Tunnel = function Tunnel (key, port, tunnelIdentifier, callback, err) {
24
24
25
25
console . log ( "Launching tunnel.." ) ;
26
26
var subProcess = exec ( tunnelCommand , function ( error , stdout , stderr ) {
27
+ console . log ( stderr ) ;
27
28
if ( stdout . indexOf ( 'Error' ) >= 0 ) {
28
29
console . log ( "..Failed" ) ;
29
30
console . log ( stdout ) ;
@@ -61,22 +62,21 @@ var Tunnel = function Tunnel (key, port, tunnelIdentifier, callback, err) {
61
62
62
63
fs . exists ( tunnelJar , function ( exists ) {
63
64
if ( exists ) {
64
- tunnelLauncher ( ) ;
65
- } else {
66
- console . log ( 'Downloading tunnel to `%s`' , tunnelJar ) ;
65
+ fs . unlinkSync ( tunnelJar ) ;
66
+ }
67
+ console . log ( 'Downloading tunnel to `%s`' , tunnelJar ) ;
67
68
68
- var file = fs . createWriteStream ( tunnelJar ) ;
69
- var request = http . get (
70
- "http://www.browserstack.com/BrowserStackTunnel.jar" ,
71
- function ( response ) {
72
- response . pipe ( file ) ;
69
+ var file = fs . createWriteStream ( tunnelJar ) ;
70
+ var request = http . get (
71
+ "http://www.browserstack.com/BrowserStackTunnel.jar" ,
72
+ function ( response ) {
73
+ response . pipe ( file ) ;
73
74
74
- response . on ( 'end' , function ( ) {
75
- tunnelLauncher ( ) ;
76
- } ) ;
77
- }
78
- ) ;
79
- }
75
+ response . on ( 'end' , function ( ) {
76
+ tunnelLauncher ( ) ;
77
+ } ) ;
78
+ }
79
+ ) ;
80
80
} ) ;
81
81
82
82
return that ;
0 commit comments