microsoft/vscode-react-native

Public

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

CodeCommitsIssuesPull requestsActionsInsightsSecurity
b0061ac657ace1a09c59d28397cb8a1b6009bc2d

Branches

Tags

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

Clone

HTTPS

Download ZIP

src/common/node/package.ts

40lines · modeblame

a31b007cunknown10 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
b0061ac6Meena Kunnathur Balakrishnan10 years ago4import {Node} from "./node";
3fb37ad5unknown10 years ago5import * as pathModule from "path";
6
7export interface IPackageInformation {
8name: string;
eb2a5b33dlebu10 years ago9dependencies: { [name: string]: string };
3fb37ad5unknown10 years ago10}
11
12export class Package {
13private _path: string;
14private INFORMATION_PACKAGE_FILENAME = "package.json";
15
16constructor(path: string) {
17this._path = path;
18}
19
e639e7a4Daniel10 years ago20public parsePackageInformation(): Q.Promise<IPackageInformation> {
3fb37ad5unknown10 years ago21return new Node.FileSystem().readFile(this.informationJsonFilePath(), "utf8")
22.then(data =>
23<IPackageInformation>JSON.parse(data));
24}
25
26public name(): Q.Promise<string> {
e639e7a4Daniel10 years ago27return this.parsePackageInformation()
28.then(packageInformation =>
29packageInformation.name);
3fb37ad5unknown10 years ago30}
31
eb2a5b33dlebu10 years ago32public dependencies(): Q.Promise<{ [name: string]: string }> {
e639e7a4Daniel10 years ago33return this.parsePackageInformation()
eb2a5b33dlebu10 years ago34.then(packageInformation => packageInformation.dependencies);
3fb37ad5unknown10 years ago35}
3736c251dlebu10 years ago36
37private informationJsonFilePath(): string {
38return pathModule.resolve(this._path, this.INFORMATION_PACKAGE_FILENAME);
39}
3d97c2a3Meena Kunnathur Balakrishnan10 years ago40}