@@ -144,6 +144,7 @@ export class IosProject extends NSProject {
144
144
. appendParamIf ( "--emulator" , args . emulator )
145
145
. appendParamIf ( "--start" , args . request === "attach" )
146
146
. appendParamIf ( "--debug-brk" , args . request === "launch" )
147
+ . appendParamIf ( "--no-rebuild" , ! args . rebuild )
147
148
. appendParam ( "--no-client" )
148
149
. appendParams ( args . tnsArgs )
149
150
. build ( ) ;
@@ -155,12 +156,19 @@ export class IosProject extends NSProject {
155
156
return new Promise < string > ( ( resolve , reject ) => {
156
157
// run NativeScript CLI command
157
158
let child : ChildProcess = this . spawnProcess ( command . path , command . args , args . tnsOutput ) ;
159
+ let synced = false ;
158
160
159
161
child . stdout . on ( 'data' , ( data ) => {
160
162
let strData : string = data . toString ( ) ;
161
163
this . emit ( 'TNS.outputMessage' , strData , 'log' ) ;
162
164
this . writeToTnsOutputFile ( strData ) ;
163
- if ( ! readyToConnect ) {
165
+ if ( ! synced && ! args . rebuild && strData . indexOf ( 'Successfully synced application' ) > - 1 ) {
166
+ synced = true ;
167
+ //wait a little before trying to connect, this gives a changes for adb to be able to connect to the debug socket
168
+ setTimeout ( ( ) => {
169
+ resolve ( ) ;
170
+ } , 500 ) ;
171
+ } else if ( ! readyToConnect ) {
164
172
let matches : RegExpMatchArray = strData . match ( socketPathPattern ) ;
165
173
if ( matches && matches . length > 0 ) {
166
174
readyToConnect = true ;
@@ -175,7 +183,13 @@ export class IosProject extends NSProject {
175
183
} ) ;
176
184
177
185
child . on ( 'close' , ( code , signal ) => {
178
- reject ( "The debug process exited unexpectedly code:" + code ) ;
186
+ if ( ! args . rebuild ) {
187
+ setTimeout ( ( ) => {
188
+ reject ( "The debug process exited unexpectedly code:" + code ) ;
189
+ } , 3000 ) ;
190
+ } else {
191
+ reject ( "The debug process exited unexpectedly code:" + code ) ;
192
+ }
179
193
} ) ;
180
194
} ) ;
181
195
}
@@ -220,6 +234,7 @@ export class AndroidProject extends NSProject {
220
234
. appendParam ( "debug" )
221
235
. appendParam ( this . platform ( ) )
222
236
. appendParamIf ( "--emulator" , args . emulator )
237
+ . appendParamIf ( "--no-rebuild" , args . rebuild !== true )
223
238
. appendParam ( "--debug-brk" )
224
239
. appendParam ( "--no-client" )
225
240
. appendParams ( args . tnsArgs )
@@ -233,13 +248,14 @@ export class AndroidProject extends NSProject {
233
248
let strData : string = data . toString ( ) ;
234
249
that . emit ( 'TNS.outputMessage' , data . toString ( ) , 'log' ) ;
235
250
that . writeToTnsOutputFile ( strData ) ;
236
- if ( ! launched && args . request === "launch" && strData . indexOf ( '# NativeScript Debugger started #' ) > - 1 ) {
237
- launched = true ;
238
-
239
- //wait a little before trying to connect, this gives a changes for adb to be able to connect to the debug socket
240
- setTimeout ( ( ) => {
241
- resolve ( ) ;
242
- } , 500 ) ;
251
+ if ( ! launched ) {
252
+ if ( args . request === "launch" && ( ( strData . indexOf ( '# NativeScript Debugger started #' ) > - 1 ) || strData . indexOf ( 'Successfully synced application' ) > - 1 ) ) {
253
+ launched = true ;
254
+ //wait a little before trying to connect, this gives a changes for adb to be able to connect to the debug socket
255
+ setTimeout ( ( ) => {
256
+ resolve ( ) ;
257
+ } , 500 ) ;
258
+ }
243
259
}
244
260
} ) ;
245
261
@@ -249,7 +265,14 @@ export class AndroidProject extends NSProject {
249
265
} ) ;
250
266
251
267
child . on ( 'close' , function ( code ) {
252
- reject ( "The debug process exited unexpectedly code:" + code ) ;
268
+ if ( ! args . rebuild ) {
269
+ setTimeout ( ( ) => {
270
+ reject ( "The debug process exited unexpectedly code:" + code ) ;
271
+ } , 3000 ) ;
272
+ }
273
+ else {
274
+ reject ( "The debug process exited unexpectedly code:" + code ) ;
275
+ }
253
276
} ) ;
254
277
} ) ;
255
278
}
0 commit comments