in src/debugger/cordovaDebugSession.ts [481:535]
private launchSimulate(launchArgs: ICordovaLaunchRequestArgs, projectType: ProjectType, generator: TelemetryGenerator): Promise<any> {
let simulateTelemetryPropts: ISimulateTelemetryProperties = {
platform: launchArgs.platform,
target: launchArgs.target,
port: launchArgs.port,
simulatePort: launchArgs.simulatePort,
};
if (launchArgs.hasOwnProperty("livereload")) {
simulateTelemetryPropts.livereload = launchArgs.livereload;
}
if (launchArgs.hasOwnProperty("livereloadDelay")) {
simulateTelemetryPropts.livereloadDelay = launchArgs.livereloadDelay;
}
if (launchArgs.hasOwnProperty("forcePrepare")) {
simulateTelemetryPropts.forcePrepare = launchArgs.forcePrepare;
}
generator.add("simulateOptions", simulateTelemetryPropts, false);
let simulateInfo: SimulationInfo;
let getEditorsTelemetry = this.workspaceManager.getVisibleEditorsCount()
.then((editorsCount) => {
generator.add("visibleTextEditors", editorsCount, false);
}).catch((e) => {
this.outputLogger(localize("CouldntoReadTheVisibleTextEditors", "Could not read the visible text editors. {0}", this.getErrorMessage(e)));
});
let launchSimulate = Promise.resolve()
.then(() => {
let simulateOptions = this.convertLaunchArgsToSimulateArgs(launchArgs);
return this.workspaceManager.launchSimulateServer(launchArgs.cwd, simulateOptions, projectType);
}).then((simInfo: SimulationInfo) => {
simulateInfo = simInfo;
return this.connectSimulateDebugHost(simulateInfo);
}).then(() => {
launchArgs.userDataDir = path.join(settingsHome(), CordovaDebugSession.CHROME_DATA_DIR);
return this.workspaceManager.launchSimHost(launchArgs.target);
}).then(() => {
// Launch Chrome and attach
launchArgs.simulatePort = CordovaProjectHelper.getPortFromURL(simulateInfo.appHostUrl);
launchArgs.url = simulateInfo.appHostUrl;
this.outputLogger(localize("AttachingToApp", "Attaching to app"));
return this.launchChromiumBasedBrowser(launchArgs);
}).catch((e) => {
this.outputLogger(localize("AnErrorOccuredWhileAttachingToTheDebugger", "An error occurred while attaching to the debugger. {0}", this.getErrorMessage(e)));
throw e;
}).then(() => void 0);
return Promise.all([launchSimulate, getEditorsTelemetry]);
}