microsoft/vscode-react-native

Public

mirrored from https://github.com/microsoft/vscode-react-nativeAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
bef522ffd9aa18ed31413b0ae0899ea09139adc3

Branches

Tags

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

Clone

HTTPS

Download ZIP

src/debugger/launcher.ts

51lines · 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 {DebuggerWorker} from "./debuggerWorker";
6import {Packager} from "./packager";
7import {Log} from "../utils/commands/log";
8import {PlatformResolver} from "./platformResolver";
9import {IRunOptions} from "./launchArgs";
10
11export class Launcher {
12 private projectRootPath: string;
13
14 constructor(projectRootPath: string) {
15 this.projectRootPath = projectRootPath;
16 }
17
18 /**
19 * Parses the launch arguments set in the launch configuration.
20 */
21 private parseRunOptions(): IRunOptions {
22 let result: IRunOptions = { projectRoot: this.projectRootPath };
23
24 if (process.argv.length > 2) {
25 result.platform = process.argv[2].toLowerCase();
26 }
27
28 result.target = process.argv[3];
29
30 return result;
31 }
32
33 public launch() {
34 let resolver = new PlatformResolver();
35 let runOptions = this.parseRunOptions();
36 let mobilePlatform = resolver.resolveMobilePlatform(runOptions.platform);
37 if (!mobilePlatform) {
38 Log.logError("The target platform could not be read. Did you forget to add it to the launch.json configuration arguments?");
39 } else {
40 Q({})
41 .then(() => Q.delay(new Packager(this.projectRootPath).start(), 3000))
42 .then(() => Q.delay(mobilePlatform.runApp(runOptions), 3000))
43 .then(() => Q.delay(new DebuggerWorker(this.projectRootPath).start(), 3000)) // Start the worker
44 .then(() => mobilePlatform.enableJSDebuggingMode(runOptions))
45 .done(() => { }, reason => {
46 Log.logError("Cannot debug application.", reason);
47 });
48 }
49 }
50}
51
52