microsoft/vscode-react-native

Public

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

CodeCommitsIssuesPull requestsActionsInsightsSecurity
bedf110fbb4cf82fb995f4cf2770e8339d5adbea

Branches

Tags

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

Clone

HTTPS

Download ZIP

src/utils/node/package.ts

35lines · modecode

1import {Node} from "../node/node";
2import * as pathModule from "path";
3
4export interface IPackageInformation {
5 // Note: We should add whatever properties we need here, as needed
6 name: string;
7}
8
9export class Package {
10 private _path: string;
11 private INFORMATION_PACKAGE_FILENAME = "package.json";
12
13 constructor(path: string) {
14 this._path = path;
15 }
16
17 private informationJsonFilePath(): string {
18 return pathModule.resolve(this._path, this.INFORMATION_PACKAGE_FILENAME);
19 }
20
21 public information(): Q.Promise<IPackageInformation> {
22 return new Node.FileSystem().readFile(this.informationJsonFilePath(), "utf8")
23 .then(data =>
24 <IPackageInformation>JSON.parse(data));
25 }
26
27 public name(): Q.Promise<string> {
28 return this.information().then(information =>
29 <string>information.name);
30 }
31
32 public path() {
33 return this._path;
34 }
35}