NPM.Platform (NPM v0.6.0)

Copy Markdown View Source

Platform compatibility checks for npm packages.

Evaluates os, cpu, and engines fields from package.json against the current system to detect incompatible packages.

Summary

Functions

Check if the engines field is satisfied.

Check if a package is compatible with the current CPU architecture.

Get the current CPU architecture in npm format.

Get the current OS name in npm format.

Check if a package is compatible with the current OS.

Functions

check_engines(engines)

@spec check_engines(%{required(String.t()) => String.t()}) :: [String.t()]

Check if the engines field is satisfied.

Returns a list of warning strings for unsatisfied engine constraints. Currently only checks the node engine as informational.

cpu_compatible?(cpu_list)

@spec cpu_compatible?([String.t()]) :: boolean()

Check if a package is compatible with the current CPU architecture.

The cpu field is an array of allowed (or disallowed with ! prefix) CPU architectures.

current_cpu()

@spec current_cpu() :: String.t()

Get the current CPU architecture in npm format.

current_os()

@spec current_os() :: String.t()

Get the current OS name in npm format.

os_compatible?(os_list)

@spec os_compatible?([String.t()]) :: boolean()

Check if a package is compatible with the current OS.

The os field is an array of allowed (or disallowed with ! prefix) operating systems.