microsoft/vscode-react-native

Public

mirrored fromhttps://github.com/microsoft/vscode-react-nativeAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
e54a23cec8f8d2b2adefd558262187fc8444f2c1

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

src/debugger/launcher.ts

55lines · modecode

1// Copyright (c) Microsoft Corporation. All rights reserved.
2// Licensed under the MIT license. See LICENSE file in the project root for details.
3
4import * as Q from "q";
5import * as path from "path";
6import {MultipleLifetimesAppWorker} from "./appWorker";
7import {Packager} from "./packager";
8import {Log} from "../utils/commands/log";
9import {PlatformResolver} from "./platformResolver";
10import {IRunOptions} from "./launchArgs";
11
12export class Launcher {
13 private projectRootPath: string;
14
15 constructor(projectRootPath: string) {
16 this.projectRootPath = projectRootPath;
17 }
18
19 /**
20 * Parses the launch arguments set in the launch configuration.
21 */
22 private parseRunOptions(): IRunOptions {
23 let result: IRunOptions = { projectRoot: this.projectRootPath };
24
25 if (process.argv.length > 2) {
26 result.platform = process.argv[2].toLowerCase();
27 }
28
29 result.target = process.argv[3];
30
31 return result;
32 }
33
34 public launch() {
35 let resolver = new PlatformResolver();
36 let runOptions = this.parseRunOptions();
37 let desktopPlatform = resolver.resolveDesktopPlatform();
38 let mobilePlatform = resolver.resolveMobilePlatform(runOptions.platform, desktopPlatform);
39 if (!mobilePlatform) {
40 Log.logError("The target platform could not be read. Did you forget to add it to the launch.json configuration arguments?");
41 } else {
42 let sourcesStoragePath = path.join(this.projectRootPath, ".vscode");
43 // TODO: We need to remove all the delays, yet make sure things work properly for both Android and iOS
44 Q({})
45 .then(() => Q.delay(new Packager(this.projectRootPath, desktopPlatform, sourcesStoragePath).start(), 3000))
46 .then(() => Q.delay(mobilePlatform.runApp(runOptions), 3000))
47 .then(() => Q.delay(new MultipleLifetimesAppWorker(sourcesStoragePath).start(), 3000)) // Start the app worker
48 .then(() => mobilePlatform.enableJSDebuggingMode(runOptions))
49 .done(() => { }, reason => {
50 Log.logError("Cannot debug application.", reason);
51 });
52 }
53 }
54}
55
56