microsoft/vscode-react-native
Publicmirrored from https://github.com/microsoft/vscode-react-nativeAvailable
src/rn-extension.ts
27lines · 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 * as vscode from "vscode"; |
| 5 | |
| 6 | import {PackageJsonWatcher} from "./utils/packageJsonWatcher"; |
| 7 | import {ReactNativeCommandHelper} from "./utils/reactNativeCommandHelper"; |
| 8 | |
| 9 | export 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 | // TODO: Change to a foreach if this implementation is appropriate |
| 17 | // Register react native commands |
| 18 | context.subscriptions.push(vscode.commands.registerCommand("reactNative.runAndroid", |
| 19 | () => ReactNativeCommandHelper.executeReactNativeCommand(vscode.workspace.rootPath, "runAndroid"))); |
| 20 | context.subscriptions.push(vscode.commands.registerCommand("reactNative.runIos", |
| 21 | () => ReactNativeCommandHelper.executeReactNativeCommand(vscode.workspace.rootPath, "runIos"))); |
| 22 | context.subscriptions.push(vscode.commands.registerCommand("reactNative.startPackager", |
| 23 | () => ReactNativeCommandHelper.executeReactNativeCommand(vscode.workspace.rootPath, "startPackager"))); |
| 24 | context.subscriptions.push(vscode.commands.registerCommand("reactNative.stopPackager", |
| 25 | () => ReactNativeCommandHelper.executeReactNativeCommand(vscode.workspace.rootPath, "stopPackager"))); |
| 26 | |
| 27 | } |