microsoft/vscode-react-native

Public

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

CodeCommitsIssuesPull requestsActionsInsightsSecurity
bef522ffd9aa18ed31413b0ae0899ea09139adc3

Branches

Tags

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

Clone

HTTPS

Download ZIP

src/utils/reactNativeCommandExecutor.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
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 public executeReactNativeCommand(command: string): void {
19 let resolver = new PlatformResolver();
20 let desktopPlatform = resolver.resolveDesktopPlatform();
21
22 // Invoke "react-native" with the command passed
23 return new CommandExecutor(this.workspaceRoot).spawn(desktopPlatform.reactNativeCommandName, [command], {}, window.createOutputChannel("React-Native")).done();
24 }
25
26 public startPackager(): void {
27 return this.reactNativePackager.start(false, window.createOutputChannel("React-Native")).done();
28 }
29
30 public stopPackager(): void {
31 return this.reactNativePackager.stop(window.createOutputChannel("React-Native"));
32 }
33}
34