microsoft/vscode-react-native

Public

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

CodeCommitsIssuesPull requestsActionsInsightsSecurity
4bd0c6691c098818360fd7858937bd9969fa5481

Branches

Tags

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

Clone

HTTPS

Download ZIP

src/debugger/launcher.ts

53lines · 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 mobilePlatform = resolver.resolveMobilePlatform(runOptions.platform);
38 if (!mobilePlatform) {
39 Log.logError("The target platform could not be read. Did you forget to add it to the launch.json configuration arguments?");
40 } else {
41 let sourcesStoragePath = path.join(this.projectRootPath, ".vscode");
42 Q({})
43 .then(() => Q.delay(new Packager(this.projectRootPath, sourcesStoragePath).start(), 3000))
44 .then(() => Q.delay(mobilePlatform.runApp(runOptions), 3000))
45 .then(() => Q.delay(new MultipleLifetimesAppWorker(sourcesStoragePath).start(), 3000)) // Start the app worker
46 .then(() => mobilePlatform.enableJSDebuggingMode(runOptions))
47 .done(() => { }, reason => {
48 Log.logError("Cannot debug application.", reason);
49 });
50 }
51 }
52}
53
54