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 · modeblame

bef522ffMeena Kunnathur Balakrishnan10 years ago1// 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 {
10private reactNativePackager: Packager;
11private workspaceRoot: string;
12
13constructor(workspaceRoot: string) {
14this.workspaceRoot = workspaceRoot;
15this.reactNativePackager = new Packager(workspaceRoot);
16}
17
0904a0d7Meena Kunnathur Balakrishnan10 years ago18/**
19* Executes a react-native command
20* {command} - the react-native command to be executed
21*/
bef522ffMeena Kunnathur Balakrishnan10 years ago22public executeReactNativeCommand(command: string): void {
23let resolver = new PlatformResolver();
24let desktopPlatform = resolver.resolveDesktopPlatform();
25
26// Invoke "react-native" with the command passed
27return new CommandExecutor(this.workspaceRoot).spawn(desktopPlatform.reactNativeCommandName, [command], {}, window.createOutputChannel("React-Native")).done();
28}
29
0904a0d7Meena Kunnathur Balakrishnan10 years ago30/**
31* Starts the React Native packager
32*/
bef522ffMeena Kunnathur Balakrishnan10 years ago33public startPackager(): void {
088101adMeena Kunnathur Balakrishnan10 years ago34return this.reactNativePackager.start(true, window.createOutputChannel("React-Native")).done();
bef522ffMeena Kunnathur Balakrishnan10 years ago35}
36
0904a0d7Meena Kunnathur Balakrishnan10 years ago37/**
38* Kills the React Native packager invoked by the extension's packager
39*/
bef522ffMeena Kunnathur Balakrishnan10 years ago40public stopPackager(): void {
41return this.reactNativePackager.stop(window.createOutputChannel("React-Native"));
42}
43}