@@ -38,14 +38,34 @@ function Local(){
38
38
that . binaryPath = binaryPath ;
39
39
childProcess . exec ( 'echo "" > ' + that . logfile ) ;
40
40
41
+ try {
42
+ if ( ! fs . existsSync ( binaryPath ) ) {
43
+ console . log ( "Binary does not exist at " , binaryPath ) ;
44
+ }
45
+ } catch ( err ) {
46
+ console . log ( "Failed to check the existence of Binary at " , binaryPath ) ;
47
+ console . error ( err ) ;
48
+ }
49
+
41
50
that . opcode = 'start' ;
42
51
that . tunnel = childProcess . execFile ( that . binaryPath , that . getBinaryArgs ( ) , function ( error , stdout , stderr ) {
43
52
if ( error ) {
44
53
console . error ( 'Error while trying to execute binary' , error ) ;
54
+ console . error ( 'STDOUT' ) ;
55
+ console . error ( stdout ) ;
56
+ console . error ( 'STDERR' ) ;
57
+ console . error ( stderr ) ;
58
+ console . error ( '------' )
45
59
if ( that . retriesLeft > 0 ) {
46
60
console . log ( 'Retrying Binary Download. Retries Left' , that . retriesLeft ) ;
47
61
that . retriesLeft -= 1 ;
48
- fs . unlinkSync ( that . binaryPath ) ;
62
+ try {
63
+ fs . unlinkSync ( that . binaryPath ) ;
64
+ } catch ( err ) {
65
+ console . error ( 'Failed to delete pre-existing binary: ' ) ;
66
+ console . error ( err ) ;
67
+ }
68
+
49
69
delete ( that . binaryPath ) ;
50
70
that . start ( options , callback ) ;
51
71
return ;
@@ -191,8 +211,8 @@ function Local(){
191
211
} ;
192
212
193
213
this . getBinaryPath = function ( callback ) {
214
+ this . binary = new LocalBinary ( ) ;
194
215
if ( typeof ( this . binaryPath ) == 'undefined' ) {
195
- this . binary = new LocalBinary ( ) ;
196
216
var conf = { } ;
197
217
if ( this . proxyHost && this . proxyPort ) {
198
218
conf . proxyHost = this . proxyHost ;
@@ -201,6 +221,12 @@ function Local(){
201
221
this . binary . binaryPath ( conf , callback ) ;
202
222
} else {
203
223
console . log ( 'BINARY PATH IS DEFINED' ) ;
224
+ if ( this . checkPath ( this . binaryPath , fs . X_OK ) ) {
225
+ console . log ( 'Binary has the correct permissions.' ) ;
226
+ } else {
227
+ console . log ( 'Binary has incorrect permissions.' ) ;
228
+ }
229
+
204
230
callback ( this . binaryPath ) ;
205
231
}
206
232
} ;
0 commit comments