@@ -96,7 +96,7 @@ function enumerate(options, callback) {
96
96
next ( ex , null ) ;
97
97
} else {
98
98
// Parse the output! Hope this regex is OK!
99
- var deviceListingRE = / ^ \s * ( \d + ) \s + ( [ \w \. ] + ) $ / mg
99
+ var deviceListingRE = / ^ \s * ( \d + ) \s + ( [ \w \. ] + ) / mg
100
100
deviceListingRE . exec ( out ) ; // skip device
101
101
var emulators = [ ] ;
102
102
var match ;
@@ -245,23 +245,17 @@ function connect(udid, options, callback) {
245
245
246
246
child . on ( 'close' , function ( code ) {
247
247
clearTimeout ( abortTimer ) ;
248
+
249
+ var errmsg = out . trim ( ) . split ( / \r \n | \n / ) . shift ( ) ,
250
+ ex = new Error ( / ^ E r r o r : / . test ( errmsg ) ? errmsg . substring ( 7 ) : __ ( 'Failed to start %s (code %s)' , dev . name , code ) ) ;
248
251
// Here's where we expect the failure that the app is not installed, which is right.
249
- if ( code == - 2146233088 ) {
250
- var errmsg = out . trim ( ) . split ( / \r \n | \n / ) . shift ( ) ,
251
- ex = new Error ( / ^ E r r o r : / . test ( errmsg ) ? errmsg . substring ( 7 ) : __ ( 'Failed to start %s (code %s)' , dev . name , code ) ) ;
252
- if ( errmsg == 'Error: The application is not installed.' ) {
253
- // we must be successful, right?
254
- emitter . emit ( 'connected' , dev ) ;
255
- callback ( null , dev ) ;
256
- } else {
257
- // we sometimes get the same code, but different error message
258
- emitter . emit ( 'error' , ex ) ;
259
- callback ( ex ) ;
260
- }
261
- }
262
- else {
263
- var errmsg = out . trim ( ) . split ( / \r \n | \n / ) . shift ( ) ,
264
- ex = new Error ( / ^ E r r o r : / . test ( errmsg ) ? errmsg . substring ( 7 ) : __ ( 'Failed to start %s (code %s)' , dev . name , code ) ) ;
252
+ // if (code == -2146233088 || code == 2148734208)
253
+ if ( errmsg . indexOf ( 'The application is not installed.' ) != - 1 ) {
254
+ // we must be successful, right?
255
+ emitter . emit ( 'connected' , dev ) ;
256
+ callback ( null , dev ) ;
257
+ } else {
258
+ // we sometimes get the same code, but different error message
265
259
emitter . emit ( 'error' , ex ) ;
266
260
callback ( ex ) ;
267
261
}
0 commit comments