microsoft/vscode-react-native

Public

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

CodeCommitsIssuesPull requestsActionsInsightsSecurity
a31b007c2af965bbb579b8e9ae0054a403891c95

Branches

Tags

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

Clone

HTTPS

Download ZIP

src/utils/node/package.ts

37lines · 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 {Node} from "../node/node";
5import * as pathModule from "path";
6
7export interface IPackageInformation {
8 name: string;
9}
10
11export class Package {
12 private _path: string;
13 private INFORMATION_PACKAGE_FILENAME = "package.json";
14
15 constructor(path: string) {
16 this._path = path;
17 }
18
19 private informationJsonFilePath(): string {
20 return pathModule.resolve(this._path, this.INFORMATION_PACKAGE_FILENAME);
21 }
22
23 public information(): Q.Promise<IPackageInformation> {
24 return new Node.FileSystem().readFile(this.informationJsonFilePath(), "utf8")
25 .then(data =>
26 <IPackageInformation>JSON.parse(data));
27 }
28
29 public name(): Q.Promise<string> {
30 return this.information().then(information =>
31 <string>information.name);
32 }
33
34 public path() {
35 return this._path;
36 }
37}