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/platformResolver.ts

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