microsoft/vscode-react-native

Public

mirrored fromhttps://github.com/microsoft/vscode-react-nativeAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
2d2a33644976c159bb50bad9df3cb949f150a8ec

Branches

Tags

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

Clone

HTTPS

Download ZIP

src/common/reactNativeProjectHelper.ts

26lines · 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 {Package} from "./node/package";
5
6export class ReactNativeProjectHelper {
7 private workspaceRoot: string;
8
9 constructor(workspaceRoot: string) {
10 this.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 */
18 public isReactNativeProject(): Q.Promise<boolean> {
19 let currentPackage = new Package(this.workspaceRoot);
20 return currentPackage.dependencies().then(dependencies => {
21 return !!(dependencies && dependencies["react-native"]);
22 }).catch((err: Error) => {
23 return Q.resolve(false);
24 });
25 }
26}
27