microsoft/vscode-react-native

Public

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

CodeCommitsIssuesPull requestsActionsInsightsSecurity
9c9df666b96d3cf35304f71c1dcf2462ea75a427

Branches

Tags

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

Clone

HTTPS

Download ZIP

src/common/reactNativeProjectHelper.ts

26lines · modeblame

3d97c2a3Meena 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 {Package} from "./node/package";
5
6export class ReactNativeProjectHelper {
7private workspaceRoot: string;
8
9constructor(workspaceRoot: string) {
10this.workspaceRoot = workspaceRoot;
11}
12
13/**
14* Ensures that we are in a React Native project and then executes the operation
15* Otherwise, displays an error message banner
16* {operation} - a function that performs the expected operation
17*/
18public isReactNativeProject(): Q.Promise<boolean> {
19let currentPackage = new Package(this.workspaceRoot);
20return currentPackage.dependencies().then(dependencies => {
21return dependencies && dependencies["react-native"];
fb8f49fbMeena Kunnathur Balakrishnan10 years ago22}).catch((err: Error) => {
3d97c2a3Meena Kunnathur Balakrishnan10 years ago23return Q.resolve(false);
24});
25}
26}