microsoft/vscode-react-native

Public

mirrored fromhttps://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/platformResolver.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 {IRunOptions} from "./launchArgs";
5
6/**
7 * Contains all the mobile platform specific debugging operations.
8 */
9export interface IMobilePlatform {
10 runApp(runOptions: IRunOptions): Q.Promise<void>;
11 enableJSDebuggingMode(runOptions: IRunOptions): Q.Promise<void>;
12}
13
14/**
15 * Contains all the desktop platform specific operations.
16 */
17export interface IDesktopPlatform {
18 reactNativeCommandName: string;
19 reactPackagerExtraParameters: string[];
20}
21
22export class PlatformResolver {
23
24 /**
25 * Resolves the dev machine, desktop platform.
26 */
27 public resolveDesktopPlatform(): IDesktopPlatform {
28 let platform = process.platform;
29 switch (platform) {
30 case "darwin":
31 return { reactNativeCommandName: "react-native", reactPackagerExtraParameters: [] };
32 case "win32":
33 default:
34 return { reactNativeCommandName: "react-native.cmd", reactPackagerExtraParameters: [] };
35 }
36 }
37
38 /**
39 * Resolves the mobile application target platform.
40 */
41 public resolveMobilePlatform(mobilePlatformString: string): IMobilePlatform {
42 switch (mobilePlatformString) {
43 // We lazyly load the strategies, because some components might be
44 // missing on some platforms (like XCode in Windows)
45 case "ios":
46 let ios = require("./ios/iOSPlatform");
47 return new ios.IOSPlatform(this.resolveDesktopPlatform());
48 case "android":
49 let android = require("./android/androidPlatform");
50 return new android.AndroidPlatform(this.resolveDesktopPlatform());
51 default:
52 return null;
53 }
54 }
55}