Skip to content

This module provides functions to get information about other not installed module. It executes npm info command to get specific data from package.json.

Notifications You must be signed in to change notification settings

rastorc3v/get-package-information

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

get-package-information


Description

This module provides functions to get information about other not installed modules in JSON format. It executes npm info command to get specific data from package.json.

Available information to get:

  • Dependencies
  • Development dependencies
  • All dependencies
  • Other fields (version, description, keywords, etc.)

API

getDependencies

import { getDependencies } from "get-package-information";

getDependencies('webpack').then((dependencies => {
    console.log(dependencies);
})); 

Result:

{
    "@types/eslint-scope": "^3.7.0",
    "@types/estree": "^0.0.50",
    "@webassemblyjs/ast": "1.11.1",
    ...
}

getDependenciesSync

import { getDependenciesSync } from "get-package-information";

const dependencies = getDependenciesSync('webpack'); 
console.log(dependencies);

Result:

{
    "@types/eslint-scope": "^3.7.0",
    "@types/estree": "^0.0.50",
    "@webassemblyjs/ast": "1.11.1",
    ...
}

getDevDependencies

import { getDevDependencies } from "get-package-information";

getDevDependencies('webpack').then((devDependencies => {
    console.log(devDependencies);
})); 

Result:

{
    "@babel/core": "^7.11.1",
    "@babel/preset-react": "7.10.4",
    "@types/es-module-lexer": "^0.4.1",
    ...
}

getDevDependenciesSync

import { getDevDependenciesSync } from "get-package-information";

const devDependencies = getDevDependenciesSync('webpack');
console.log(devDependencies);

Result:

{
    "@babel/core": "^7.11.1",
    "@babel/preset-react": "7.10.4",
    "@types/es-module-lexer": "^0.4.1",
    ...
}

getAllDependencies

import { getAllDependencies } from "get-package-information";

getAllDependencies('webpack').then((dependencies => {
    console.log(dependencies);
})); 

Result:

{
  "dependencies": {
    "@types/eslint-scope": "^3.7.0",
    "@types/estree": "^0.0.50",
    ...
  },
  "devDependencies": {
    "@babel/core": "^7.11.1",
    "@babel/preset-react": "^7.10.4",
    ...
  }
}

getAllDependenciesSync

import { getAllDependencies } from "get-package-information";

const dependencies = getAllDependencies('webpack');
console.log(dependencies);

Result:

{
  "dependencies": {
    "@types/eslint-scope": "^3.7.0",
    "@types/estree": "^0.0.50",
    ...
  },
  "devDependencies": {
    "@babel/core": "^7.11.1",
    "@babel/preset-react": "^7.10.4",
    ...
  }
}

getFields

import { getFields } from "get-package-information";

getFields('webpack', ['author', 'description', 'repository']).then(info => {
    console.log(info);
    console.log(info.repository.url);
});

Result:

{
  "author": 'Tobias Koppers @sokra',
  "description": 'Packs CommonJs/AMD modules for the browser...',
  "repository": { "type": 'git', "url": 'git+https://github.com/webpack/webpack.git' }
}
git+https://github.com/webpack/webpack.git

getFieldsSync

import { getFieldsSync } from "get-package-information";

const info = getFieldsSync('webpack', ['author', 'description', 'repository']);
console.log(info);
console.log(info.repository.url)

Result:

{
  "author": 'Tobias Koppers @sokra',
  "description": 'Packs CommonJs/AMD modules for the browser...',
  "repository": { "type": 'git', "url": 'git+https://github.com/webpack/webpack.git' }
}
git+https://github.com/webpack/webpack.git

About

This module provides functions to get information about other not installed module. It executes npm info command to get specific data from package.json.

Resources

Stars

Watchers

Forks

Packages

No packages published