NPM.Exec (NPM v0.6.0)

Copy Markdown View Source

npx-style execution — resolve and run binaries from installed packages.

Looks up binaries in node_modules/.bin/ or resolves from package bin fields to find the right executable.

Summary

Functions

Lists all available binaries from installed packages.

Checks if a command is available in node_modules.

Builds the execution environment with node_modules/.bin in PATH.

Resolves a package name from a command by checking bin fields.

Finds the path to a binary command in node_modules/.bin/.

Functions

available(node_modules_dir \\ "node_modules")

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

Lists all available binaries from installed packages.

available?(command, node_modules_dir \\ "node_modules")

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

Checks if a command is available in node_modules.

env(node_modules_dir \\ "node_modules")

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

Builds the execution environment with node_modules/.bin in PATH.

package_for(command, node_modules_dir \\ "node_modules")

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

Resolves a package name from a command by checking bin fields.

which(command, node_modules_dir \\ "node_modules")

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

Finds the path to a binary command in node_modules/.bin/.