microsoft/vscode-react-native
Publicmirrored from https://github.com/microsoft/vscode-react-nativeAvailable
src/extension/debuggingConfiguration/configurationProviders/runConfigProvider.ts
67lines · 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 { BaseConfigProvider } from "./baseConfigProvider"; |
| 5 | import { MultiStepInput, InputStep } from "../multiStepInput"; |
| 6 | import { |
| 7 | DebugConfigurationState, |
| 8 | platformTypeRunPickConfig, |
| 9 | DEBUG_TYPES, |
| 10 | DebugScenarioType, |
| 11 | } from "../debugConfigTypesAndConstants"; |
| 12 | import { PlatformType } from "../../launchArgs"; |
| 13 | import { ILaunchRequestArgs } from "../../../debugger/debugSessionBase"; |
| 14 | |
| 15 | export class RunConfigProvider extends BaseConfigProvider { |
| 16 | constructor() { |
| 17 | super(); |
| 18 | this.maxStepCount = 2; |
| 19 | } |
| 20 | |
| 21 | public async buildConfiguration( |
| 22 | input: MultiStepInput<DebugConfigurationState>, |
| 23 | state: DebugConfigurationState, |
| 24 | ): Promise<InputStep<DebugConfigurationState> | void> { |
| 25 | state.config = {}; |
| 26 | const config: Partial<ILaunchRequestArgs> = { |
| 27 | name: "Run application", |
| 28 | request: "launch", |
| 29 | type: DEBUG_TYPES.REACT_NATIVE, |
| 30 | cwd: "${workspaceFolder}", |
| 31 | enableDebug: false, |
| 32 | }; |
| 33 | |
| 34 | state.scenarioType = DebugScenarioType.RunApp; |
| 35 | |
| 36 | await this.configurationProviderHelper.selectPlatform( |
| 37 | input, |
| 38 | config, |
| 39 | platformTypeRunPickConfig, |
| 40 | 1, |
| 41 | this.maxStepCount, |
| 42 | ); |
| 43 | |
| 44 | Object.assign(state.config, config); |
| 45 | |
| 46 | if ( |
| 47 | state.config.platform === PlatformType.iOS || |
| 48 | state.config.platform === PlatformType.Android |
| 49 | ) { |
| 50 | return () => this.configureApplicationType(input, state.config); |
| 51 | } else { |
| 52 | return; |
| 53 | } |
| 54 | } |
| 55 | |
| 56 | private async configureApplicationType( |
| 57 | input: MultiStepInput<DebugConfigurationState>, |
| 58 | config: Partial<ILaunchRequestArgs>, |
| 59 | ): Promise<InputStep<DebugConfigurationState> | void> { |
| 60 | await this.configurationProviderHelper.selectApplicationType( |
| 61 | input, |
| 62 | config, |
| 63 | 2, |
| 64 | this.maxStepCount, |
| 65 | ); |
| 66 | } |
| 67 | } |