microsoft/vscode-react-native

Public

mirrored from https://github.com/microsoft/vscode-react-nativeAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
0904a0d7ddf15d888e1d494ac66aa4f27e49aefb

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

src/utils/reactNativeCommandExecutor.ts

43lines · 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 {CommandExecutor} from "./commands/commandExecutor";
5import {PlatformResolver} from "./../debugger/platformResolver";
6import {Packager} from "./../debugger/packager";
7import {window} from "vscode";
8
9export class ReactNativeCommandExecutor {
10 private reactNativePackager: Packager;
11 private workspaceRoot: string;
12
13 constructor(workspaceRoot: string) {
14 this.workspaceRoot = workspaceRoot;
15 this.reactNativePackager = new Packager(workspaceRoot);
16 }
17
18 /**
19 * Executes a react-native command
20 * {command} - the react-native command to be executed
21 */
22 public executeReactNativeCommand(command: string): void {
23 let resolver = new PlatformResolver();
24 let desktopPlatform = resolver.resolveDesktopPlatform();
25
26 // Invoke "react-native" with the command passed
27 return new CommandExecutor(this.workspaceRoot).spawn(desktopPlatform.reactNativeCommandName, [command], {}, window.createOutputChannel("React-Native")).done();
28 }
29
30 /**
31 * Starts the React Native packager
32 */
33 public startPackager(): void {
34 return this.reactNativePackager.start(true, window.createOutputChannel("React-Native")).done();
35 }
36
37 /**
38 * Kills the React Native packager invoked by the extension's packager
39 */
40 public stopPackager(): void {
41 return this.reactNativePackager.stop(window.createOutputChannel("React-Native"));
42 }
43}
44