microsoft/vscode-react-native

Public

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

CodeCommitsIssuesPull requestsActionsInsightsSecurity
2ec44b6d62529aa08a88dc1dbe190833e1838036

Branches

Tags

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

Clone

HTTPS

Download ZIP

src/utils/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
3fb37ad5unknown10 years ago4import {Node} from "../node/node";
5import * 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
20private informationJsonFilePath(): string {
21return pathModule.resolve(this._path, this.INFORMATION_PACKAGE_FILENAME);
22}
23
e639e7a4Daniel10 years ago24public parsePackageInformation(): Q.Promise<IPackageInformation> {
3fb37ad5unknown10 years ago25return new Node.FileSystem().readFile(this.informationJsonFilePath(), "utf8")
26.then(data =>
27<IPackageInformation>JSON.parse(data));
28}
29
30public name(): Q.Promise<string> {
e639e7a4Daniel10 years ago31return this.parsePackageInformation()
32.then(packageInformation =>
33packageInformation.name);
3fb37ad5unknown10 years ago34}
35
eb2a5b33dlebu10 years ago36public dependencies(): Q.Promise<{ [name: string]: string }> {
e639e7a4Daniel10 years ago37return this.parsePackageInformation()
eb2a5b33dlebu10 years ago38.then(packageInformation => packageInformation.dependencies);
3fb37ad5unknown10 years ago39}
3d97c2a3Meena Kunnathur Balakrishnan10 years ago40}