Module: services/package-json-helpers

Common functions and utilities for tasks related to package.json

Source:

Members

(inner, constant) isDependencyMap :Joi

Joi schema for validating dependency map.

Type:
  • Joi
Source:

(inner, constant) isPackageJsonWithDependencies :Joi

Joi schema for validating package json object. Checks if the object has all the dependency types and the dependency types are valid.

Type:
  • Joi
Source:

Methods

(inner) getDependencyVersion(attrs) → {string}

Determines the dependency version based on the dependency type.

Parameters:
Name Type Description
attrs object

Refer to individual attributes

Properties
Name Type Description
kind string

Wanted dependency type, defaults to prod

wantedDependency string

Name of the wanted dependency

dependencies object

Map of dependencies

devDependencies object

Map of dev dependencies

peerDependencies object

Map of peer dependencies

optionalDependencies object

Map of optional dependencies

Source:
Throws:
    • Error message if unknown dependency type provided
    Type
    string
    • Error if wanted dependency is not present
    Type
    InvalidParameter
Returns:

Semver range of the wanted dependency (eg. ~2.1.6 or >=3.0.0 or <4.0.0)

Type
string