Metastatic.Priv (Metastatic v0.33.0)

View Source

Utilities for resolving parser assets in priv/ and locating runtime executables (including mise shims and global tool installations) across development, dependency, and OTP release environments.

Summary

Functions

Finds an executable by name, checking System.find_executable/1 as well as standard mise shim and user-local binary directories.

Resolves a path relative to priv/ (such as "parsers/javascript/parser.js" or "priv/parsers/javascript/parser.js").

Builds environment variables for subprocess execution.

Functions

find_executable(name)

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

Finds an executable by name, checking System.find_executable/1 as well as standard mise shim and user-local binary directories.

parser_path(relative_path)

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

Resolves a path relative to priv/ (such as "parsers/javascript/parser.js" or "priv/parsers/javascript/parser.js").

Searches :metastatic's application priv directory, compile-time source priv, :ragex's priv directory (when present), and the current working directory's priv.

subprocess_env(extra \\ [])

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

Builds environment variables for subprocess execution.

By default this augments PATH with the mise shims directory and ~/.local/bin, and NODE_PATH with the mise global node_modules. These defaults exist to make the subprocess bridges work out of the box on developer machines that use mise.

Host applications can override or replace this entirely with:

config :metastatic, :subprocess_env, [{"PATH", "/my/path"}]

When :subprocess_env is configured, it is used verbatim (the caller's extra entries are still merged on top).