Skip to content

Commit 5dbfa6b

Browse files
committed
Merge pull request #45 from NativeScript/buhov/android-get-debug-port-fix
Reorder getting debug port and attaching on android
2 parents bcd59cf + a12b5bc commit 5dbfa6b

File tree

1 file changed

+17
-21
lines changed

1 file changed

+17
-21
lines changed

src/webkit/webKitDebugAdapter.ts

+17-21
Original file line numberDiff line numberDiff line change
@@ -148,30 +148,26 @@ export class WebKitDebugAdapter implements IDebugAdapter {
148148

149149
androidProject.on('TNS.outputMessage', (message, level) => thisAdapter.onTnsOutputMessage.apply(thisAdapter, [message, level]));
150150

151-
let port: number;
152151
this.onTnsOutputMessage("Getting debug port");
153152
let androidConnection: AndroidDebugConnection = null;
154-
return androidProject.getDebugPort(args)
155-
.then(debugPort => {
156-
port = debugPort;
157-
if (!thisAdapter._webKitConnection) {
158-
return androidProject.createConnection().then(connection => {
159-
androidConnection = connection;
160-
this.setConnection(connection, args);
161-
return Promise.resolve<void>();
162-
});
163-
}
164153

165-
return Promise.resolve<void>();
166-
})
167-
.then(() => {
168-
this.onTnsOutputMessage("Preparing for debug");
169-
return androidProject.debug(args);
170-
})
171-
.then(() => {
172-
this.onTnsOutputMessage("Attaching to debug application");
173-
return androidConnection.attach(port, 'localhost');
174-
});
154+
let runDebugCommand: Promise<any> = (args.request == 'launch') ? androidProject.debug(args) : Promise.resolve();
155+
156+
return runDebugCommand.then(_ => {
157+
let port: number;
158+
return androidProject.getDebugPort(args).then(debugPort => {
159+
port = debugPort;
160+
if (!thisAdapter._webKitConnection) {
161+
return androidProject.createConnection().then(connection => {
162+
androidConnection = connection;
163+
this.setConnection(connection, args);
164+
});
165+
}
166+
}).then(() => {
167+
this.onTnsOutputMessage("Attaching to debug application");
168+
return androidConnection.attach(port, 'localhost');
169+
});
170+
});
175171
}
176172

177173
private setConnection(connection: ns.INSDebugConnection, args: IAttachRequestArgs | ILaunchRequestArgs) : ns.INSDebugConnection {

0 commit comments

Comments
 (0)