microsoft/vscode-react-native
Publicmirrored fromhttps://github.com/microsoft/vscode-react-nativeAvailable
src/debugger/platformResolver.ts
35lines · 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 | |
| 4 | import {IRunOptions} from "../common/launchArgs"; |
| 5 | import * as IOSPlatform from "./ios/iOSPlatform"; |
| 6 | import * as AndroidPlatform from "./android/androidPlatform"; |
| 7 | |
| 8 | /** |
| 9 | * Contains all the mobile platform specific debugging operations. |
| 10 | */ |
| 11 | export interface IAppPlatform { |
| 12 | runApp(runOptions: IRunOptions): Q.Promise<void>; |
| 13 | enableJSDebuggingMode(runOptions: IRunOptions): Q.Promise<void>; |
| 14 | } |
| 15 | |
| 16 | export class PlatformResolver { |
| 17 | |
| 18 | /** |
| 19 | * Resolves the mobile application target platform. |
| 20 | */ |
| 21 | public resolveMobilePlatform(mobilePlatformString: string): IAppPlatform { |
| 22 | switch (mobilePlatformString) { |
| 23 | // We lazyly load the strategies, because some components might be |
| 24 | // missing on some platforms (like XCode in Windows) |
| 25 | case "ios": |
| 26 | let ios: typeof IOSPlatform = require("./ios/iOSPlatform"); |
| 27 | return new ios.IOSPlatform(); |
| 28 | case "android": |
| 29 | let android: typeof AndroidPlatform = require("./android/androidPlatform"); |
| 30 | return new android.AndroidPlatform(); |
| 31 | default: |
| 32 | return null; |
| 33 | } |
| 34 | } |
| 35 | } |