NPM.NodeVersion (NPM v0.6.0)

Copy Markdown View Source

Parses Node.js version pinning files (.nvmrc, .node-version, .tool-versions).

Summary

Functions

Checks if a version string includes an alias (lts/*, etc).

Detects and reads the Node.js version from project files.

Checks if a version string looks like a major-only version.

Normalizes version to include all three parts.

Parses a .nvmrc file content.

Parses a .tool-versions file to extract the node version.

Functions

alias?(version)

@spec alias?(String.t()) :: boolean()

Checks if a version string includes an alias (lts/*, etc).

detect(project_dir \\ ".")

@spec detect(String.t()) :: {:ok, String.t(), String.t()} | :not_found

Detects and reads the Node.js version from project files.

major_only?(version)

@spec major_only?(String.t()) :: boolean()

Checks if a version string looks like a major-only version.

normalize(version)

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

Normalizes version to include all three parts.

parse_nvmrc(content)

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

Parses a .nvmrc file content.

parse_tool_versions(content)

@spec parse_tool_versions(String.t()) :: String.t() | nil

Parses a .tool-versions file to extract the node version.