microsoft/vscode-react-native
Publicmirrored fromhttps://github.com/microsoft/vscode-react-nativeAvailable
src/debugger/platformResolver.ts
33lines · 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 {IOSPlatform} from "./ios/iOSPlatform"; |
| 6 | import {AndroidPlatform} from "../common/android/androidPlatform"; |
| 7 | |
| 8 | /** |
| 9 | * Contains all the mobile platform specific debugging operations. |
| 10 | */ |
| 11 | export interface IAppPlatform { |
| 12 | runApp(): Q.Promise<void>; |
| 13 | enableJSDebuggingMode(): Q.Promise<void>; |
| 14 | } |
| 15 | |
| 16 | export class PlatformResolver { |
| 17 | |
| 18 | /** |
| 19 | * Resolves the mobile application target platform. |
| 20 | */ |
| 21 | public resolveMobilePlatform(mobilePlatformString: string, runOptions: IRunOptions): 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 | return new IOSPlatform(runOptions); |
| 27 | case "android": |
| 28 | return new AndroidPlatform(runOptions); |
| 29 | default: |
| 30 | return null; |
| 31 | } |
| 32 | } |
| 33 | } |