NPM.Resolutions (NPM v0.6.0)

Copy Markdown View Source

Handles yarn-style resolutions in package.json.

Resolutions allow pinning specific versions of nested dependencies, similar to npm overrides but following the Yarn convention.

Summary

Functions

Applies resolutions to a lockfile.

Checks if a package name matches a resolution pattern.

Parses resolutions from package.json data.

Finds the resolution version for a package, if any.

Types

resolution()

@type resolution() :: %{pattern: String.t(), version: String.t()}

Functions

apply_resolutions(lockfile, resolutions)

@spec apply_resolutions(map(), [resolution()]) :: {map(), non_neg_integer()}

Applies resolutions to a lockfile.

matches?(name, pattern)

@spec matches?(String.t(), String.t()) :: boolean()

Checks if a package name matches a resolution pattern.

Supports exact match and glob-style **/package patterns.

parse(arg1)

@spec parse(map()) :: [resolution()]

Parses resolutions from package.json data.

resolve(name, resolutions)

@spec resolve(String.t(), [resolution()]) :: String.t() | nil

Finds the resolution version for a package, if any.