NPM.Lifecycle (NPM v0.6.0)

Copy Markdown View Source

Detect and manage npm lifecycle scripts.

npm packages can define preinstall, install, postinstall, prepare, and other scripts in their package.json.

By default, npm_ex does NOT run lifecycle scripts for security. This module provides detection and opt-in execution.

Summary

Functions

Detect lifecycle scripts in a package's package.json.

Detect lifecycle scripts across all packages in node_modules.

List the install hook names.

Functions

detect(package_json_path)

@spec detect(String.t()) :: [{String.t(), String.t()}]

Detect lifecycle scripts in a package's package.json.

Returns a list of {hook_name, command} tuples for install-related hooks.

detect_all(node_modules_dir)

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

Detect lifecycle scripts across all packages in node_modules.

Returns a map of package_name => [{hook, command}] for packages that have install-related scripts.

hook_names()

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

List the install hook names.