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/rn-extension.ts

28lines · 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 * as vscode from "vscode";
5
6import {PackageJsonWatcher} from "./utils/packageJsonWatcher";
7import {ReactNativeCommandExecutor} from "./utils/reactNativeCommandExecutor";
8
9export function activate(context: vscode.ExtensionContext): void {
10 // TODO: Get the project root (vscode.workspace.rootPath) and return if it is not a react-native project
11 // check if package.json of user project has dependency on react-native
12
13 let packageJsonWatcher = new PackageJsonWatcher();
14 packageJsonWatcher.startWatching();
15
16 let reactNativeCommandExecutor = new ReactNativeCommandExecutor(vscode.workspace.rootPath);
17
18 // TODO: Change to a foreach if this implementation is appropriate
19 // Register react native commands
20 context.subscriptions.push(vscode.commands.registerCommand("reactNative.runAndroid",
21 () => reactNativeCommandExecutor.executeReactNativeCommand("run-android")));
22 context.subscriptions.push(vscode.commands.registerCommand("reactNative.runIos",
23 () => reactNativeCommandExecutor.executeReactNativeCommand("run-ios")));
24 context.subscriptions.push(vscode.commands.registerCommand("reactNative.startPackager",
25 () => reactNativeCommandExecutor.startPackager()));
26 context.subscriptions.push(vscode.commands.registerCommand("reactNative.stopPackager",
27 () => reactNativeCommandExecutor.stopPackager()));
28}