microsoft/vscode-react-native

Public

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

CodeCommitsIssuesPull requestsActionsInsightsSecurity
0.6.6

Branches

Tags

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

Clone

HTTPS

Download ZIP

src/extension/windows/windowsPlatform.ts

73lines · modeblame

299883f9Artem Egorov8 years ago1// 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";
5
6import {GeneralMobilePlatform, MobilePlatformDeps } from "../generalMobilePlatform";
7import {IWindowsRunOptions} from "../launchArgs";
8import {OutputVerifier, PatternToFailure} from "../../common/outputVerifier";
9import {TelemetryHelper} from "../../common/telemetryHelper";
10import {CommandExecutor} from "../../common/commandExecutor";
11import {ReactNativeProjectHelper} from "../../common/reactNativeProjectHelper";
12
13/**
14* Windows specific platform implementation for debugging RN applications.
15*/
16export class WindowsPlatform extends GeneralMobilePlatform {
17
18private static SUCCESS_PATTERNS = [
19"Installing new version of the app",
20"Starting the app",
21];
22private static FAILURE_PATTERNS: PatternToFailure[] = [
23{
24pattern: "Unrecognized command 'run-windows'",
25message: "'rnpm-plugin-windows' doesn't install",
26},
27];
28
29constructor(protected runOptions: IWindowsRunOptions, platformDeps: MobilePlatformDeps = {}) {
30super(runOptions, platformDeps);
31}
32
33public runApp(enableDebug: boolean = true): Q.Promise<void> {
34return TelemetryHelper.generate("WindowsPlatform.runApp", () => {
35const runArguments = this.getRunArgument();
36const env = this.getEnvArgument();
37
38if (enableDebug) {
39runArguments.push("--proxy");
40}
41
42return ReactNativeProjectHelper.getReactNativeVersion(this.runOptions.projectRoot)
43.then(version => {
44// TODO Uncomment when it will be implemented in `react-native-windows`
45// if (semver.gte(version, WindowsPlatform.NO_PACKAGER_VERSION)) {
46// runArguments.push("--no-packager");
47// }
48
49const runWindowsSpawn = new CommandExecutor(this.projectPath, this.logger).spawnReactCommand("run-windows", runArguments, {env});
50return new OutputVerifier(() => Q(WindowsPlatform.SUCCESS_PATTERNS), () => Q(WindowsPlatform.FAILURE_PATTERNS))
51.process(runWindowsSpawn);
52});
53});
54}
55
56public prewarmBundleCache(): Q.Promise<void> {
57return this.packager.prewarmBundleCache("windows");
58}
59
60public getRunArgument(): string[] {
61let runArguments: string[] = [];
62
63if (this.runOptions.runArguments && this.runOptions.runArguments.length > 0) {
64runArguments.push(...this.runOptions.runArguments);
65} else {
66if (this.runOptions.target) {
67runArguments.push(this.runOptions.target === "device" ? this.runOptions.target : "emulator");
68}
69}
70
71return runArguments;
72}
73}