NPM.Hooks (NPM v0.6.0)

Copy Markdown View Source

Hooks for integrating npm operations with Mix workflows.

Provides callbacks that can be triggered before and after npm operations, useful for mix compiler integration and build pipelines.

Summary

Functions

Available hook points.

List all configured hooks.

Check if a hook is configured.

Run a hook callback if configured.

Types

hook()

@type hook() :: :pre_install | :post_install | :pre_resolve | :post_resolve

Functions

available()

@spec available() :: [hook()]

Available hook points.

configured()

@spec configured() :: %{required(hook()) => term()}

List all configured hooks.

configured?(hook)

@spec configured?(hook()) :: boolean()

Check if a hook is configured.

run(hook, context \\ [])

@spec run(
  hook(),
  keyword()
) :: :ok

Run a hook callback if configured.

Hooks are configured via application config:

config :npm, hooks: %{
  post_install: {MyApp, :on_npm_install, []}
}