@@ -23,7 +23,7 @@ export class AndroidProject extends Project {
2323 const debugProcess : ChildProcess = super . executeDebugCommand ( args ) ;
2424 const tnsOutputEventEmitter = new EventEmitter ( ) ;
2525
26- this . configureReadyEvent ( debugProcess . stdout , tnsOutputEventEmitter , true ) ;
26+ this . configureReadyEvent ( debugProcess . stdout , tnsOutputEventEmitter , false ) ;
2727
2828 return { tnsProcess : debugProcess , tnsOutputEventEmitter } ;
2929 }
@@ -38,25 +38,23 @@ export class AndroidProject extends Project {
3838 const debugProcess : ChildProcess = super . executeDebugCommand ( args ) ;
3939 const tnsOutputEventEmitter : EventEmitter = new EventEmitter ( ) ;
4040
41- this . configureReadyEvent ( debugProcess . stdout , tnsOutputEventEmitter , false ) ;
41+ this . configureReadyEvent ( debugProcess . stdout , tnsOutputEventEmitter , args . indexOf ( '--debug-brk' ) > - 1 ) ;
4242
4343 return { tnsProcess : debugProcess , tnsOutputEventEmitter } ;
4444 }
4545
46- protected configureReadyEvent ( readableStream : stream . Readable , eventEmitter : EventEmitter , attach ?: boolean ) : void {
46+ protected configureReadyEvent ( readableStream : stream . Readable , eventEmitter : EventEmitter , debugBrk ?: boolean ) : void {
4747 super . configureReadyEvent ( readableStream , eventEmitter ) ;
48-
4948 let debugPort = null ;
5049
5150 new scanner . StringMatchingScanner ( readableStream ) . onEveryMatch ( new RegExp ( 'device: .* debug port: [0-9]+' ) , ( match : scanner . IMatchFound ) => {
5251 // device: {device-name} debug port: {debug-port}
5352 debugPort = parseInt ( ( match . matches [ 0 ] as string ) . match ( '(?:debug port: )([\\d]{5})' ) [ 1 ] , 10 ) ;
54- if ( attach ) {
55- // wait a little before trying to connect, this gives a chance for adb to be able to connect to the debug socket
53+ if ( ! debugBrk ) {
5654 setTimeout ( ( ) => { eventEmitter . emit ( 'readyForConnection' , debugPort ) ; } , 1000 ) ;
5755 }
5856 } ) ;
59- if ( ! attach ) {
57+ if ( debugBrk ) {
6058 new scanner . StringMatchingScanner ( readableStream ) . onEveryMatch ( '# NativeScript Debugger started #' , ( match : scanner . IMatchFound ) => {
6159 // wait a little before trying to connect, this gives a chance for adb to be able to connect to the debug socket
6260 setTimeout ( ( ) => { eventEmitter . emit ( 'readyForConnection' , debugPort ) ; } , 1000 ) ;
0 commit comments