Expand description
Lifecycle script runner for aube.
Security model:
- Scripts from the root package (the project’s own
package.json) run by default. They’re written by the user, so they’re trusted the same way a user trustsaube run <script>. - Scripts from installed dependencies (e.g.
node-gyppostinstall from a native module) are SKIPPED by default. A package runs its lifecycle scripts only if the activeBuildPolicyallows it — configured viapnpm.allowBuildsinpackage.json,allowBuildsinaube-workspace.yaml(orpnpm-workspace.yaml), or the escape-hatch--dangerously-allow-all-buildsflag. --ignore-scriptsforces everything off, matching pnpm/npm.
Re-exports§
pub use content_sniff::Suspicion;pub use content_sniff::SuspicionKind;pub use content_sniff::sniff_lifecycle;pub use policy::AllowDecision;pub use policy::BuildPolicy;pub use policy::BuildPolicyError;pub use policy::pattern_matches;
Modules§
- content_
sniff - Lightweight content scanner for dependency lifecycle script bodies.
- policy
- Allowlist/denylist policy for running dependency lifecycle scripts.
Structs§
- Script
Jail - Native build jail applied to dependency lifecycle scripts.
- Script
Jail Home Cleanup - Script
Settings - Settings that affect every package-script shell aube spawns.
Enums§
- Error
- Lifecycle
Hook - Lifecycle hooks that
aube installruns against the root package’sscriptsfield, in this order:preinstall→ (dependencies link) →install→postinstall→prepare. Matches pnpm / npm.
Constants§
- DEP_
LIFECYCLE_ HOOKS - Dependency lifecycle hooks, in the order aube runs them for each
allowlisted package.
prepareis intentionally omitted — it’s meant for the root package and git-dep preparation, not installed tarballs.
Functions§
- aube_
user_ agent - User agent string exported to lifecycle scripts as
npm_config_user_agent. Mirrors pnpm’s format (<name>/<version> <os> <arch>) so dep build scripts that sniff the env var to detect the running PM (e.g.husky,unrs-resolver) recognize aube without falling back to npm-mode. OS/arch use Node’sprocess.platform/process.archvocabulary (darwin/linux/win32,x64/arm64), not Rust’s nativestd::env::consts::{OS,ARCH}values, so tools that parse the full UA string identify the platform the same way npm/yarn/pnpm do. - child_
stderr - Returns a
Stdiosuitable for a child process’s stderr. When silent mode is active, this dups the saved real-stderr fd so the child bypasses the/dev/nullredirect on fd 2. Otherwise returnsStdio::inherit(). - default_
install_ script - Default
installcommand for a materialized dependency directory. Thin wrapper aroundimplicit_install_scriptthat supplieshas_binding_gypby stat’ing<package_dir>/binding.gyp. - exit_
code_ from_ status - Translate child ExitStatus to a parent exit code.
- has_
dep_ lifecycle_ work - True if
run_dep_hookwould actually execute something for this package across any of the dependency lifecycle hooks. Callers use this to skip fan-out work for packages that have nothing to run — including the implicitnode-gyp rebuilddefault. - implicit_
install_ script - Single source of truth for the implicit
node-gyp rebuildfallback: returnsSome("node-gyp rebuild")when the package ships abinding.gypat its root AND the manifest leaves bothinstallandpreinstallempty (either one is the author’s explicit opt-out from the default). - prepend_
path - Prepend
bin_dirto the currentPATHusing the platform’s path separator (:on Unix,;on Windows). - run_
dep_ hook - Run a lifecycle hook against an installed dependency’s package
directory. Mirrors
run_root_hookbut spawns insidepackage_dir(the actual linked package directory, e.g.node_modules/.aube/<dep_path>/node_modules/<name>). The manifest is the dependency’s ownpackage.json, not the project root’s. - run_
root_ hook - Run a lifecycle hook against the root package, if a script for it is
defined. Returns
Ok(false)if the hook wasn’t defined (no-op),Ok(true)if it ran successfully. - run_
root_ script_ by_ name - Run a named root-package script if it’s defined. Used by commands
(pack, publish, version) that need to run lifecycle hooks outside
the install-focused
LifecycleHookenum. ReturnsOk(false)if the script isn’t defined. - run_
script - Run a single npm-style script line through
sh -cwith the usual environment ($PATHextended withnode_modules/.bin,INIT_CWD,npm_lifecycle_event,npm_package_name,npm_package_version). - set_
saved_ stderr_ fd - Called once by
aubeafter it saves + redirects fd 2. Passing the caller-owned saved fd here means child processes spawned viachild_stderr()will write to the real terminal stderr instead of/dev/null. - set_
script_ settings - Replace the process-wide script settings snapshot. CLI commands call
this after resolving
.npmrc/ workspace settings for the active project. - shell_
quote_ arg - Shell-quote one arg for safe splicing into a shell command line.
- spawn_
shell - Spawn a shell command line. On Unix we go through
sh -c, on Windows throughcmd.exe /d /s /c— matching what npm passes in@npmcli/run-script. - write_
line_ to_ real_ stderr - Write
lineplus a newline to the parent’s real stderr. Used by the recursive-run output multiplexer, which pipes child stderr through aube and re-emits each line with a<package>:prefix —eprintln!writes to fd 2, whichSilentStderrGuardhas redirected to/dev/nullunder--silent, so child stderr would otherwise be silently swallowed in--silent --parallelmode. Routes through the saved real-stderr fd when silent mode is active, fd 2 otherwise.