NPM.Patch (NPM v0.6.0)

Copy Markdown View Source

Manages patched packages (patch-package style).

Tracks patches applied to node_modules packages and verifies they are still applied after install.

Summary

Functions

Returns the count of patches.

Extracts the package name from a patch filename.

Generates a patch filename for a package.

Lists all patch files in the patches directory.

Checks if a package has patches.

Returns all patched package names.

Functions

count(project_dir \\ ".")

@spec count(String.t()) :: non_neg_integer()

Returns the count of patches.

extract_package_name(filename)

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

Extracts the package name from a patch filename.

Supports formats like lodash+4.17.21.patch and @scope+pkg+1.0.0.patch.

filename(package_name, version)

@spec filename(String.t(), String.t()) :: String.t()

Generates a patch filename for a package.

list(project_dir \\ ".")

@spec list(String.t()) :: [%{package: String.t(), file: String.t()}]

Lists all patch files in the patches directory.

patched?(package_name, project_dir \\ ".")

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

Checks if a package has patches.

patched_packages(project_dir \\ ".")

@spec patched_packages(String.t()) :: [String.t()]

Returns all patched package names.