@tola-scripts/context

Read invocation paths, stage metadata, and options inside a build hook, module command, or initializer.

main

sh
tola nu @tola-scripts/context [OPTIONS]

Return the active execution context provided by Tola.

Available only when invoked by Tola inside a build hook, module command, or site initializer; running it directly in a shell returns an error. Temporary directories and reportPath are scoped to the current run.

FieldAvailability and meaning
executablePath to the running tola binary.
inputScopeActive input policy: online, offline, or pure.
site.root, site.configPath, site.contentRootSite root, tola.toml path, and content directory (build hooks and module commands). A before-build hook may write generated .typ sources under site.contentRoot.
module.name, module.root, module.manifestModule alias, root directory, and tola-module.toml path (module hooks, commands, and initializers).
module.optionsResolved module options table for the site (module hooks and commands).
hook.name, hook.stage, hook.tempDirConfigured hook name, stage, and per-run temporary directory (build hooks and before-pack).
hook.mode, hook.cacheDirBuild mode (prod or dev) and persistent cache directory across runs (build hooks).
hook.inputDirCompiled outputs in generate-outputs, published directory in after-publish, or module source root in before-pack.
hook.outputDirStaging directory where generate-outputs writes files declared in outputs.
init.outputDir, init.targetDir, init.interactiveInitializer staging directory, final target site directory for relative paths, and whether terminal prompts are permitted.
reportPathFile path where external hooks or module commands may write a JSON diagnostic report before exiting.

Options

  • --json: Emit JSON text instead of a Nu record. Useful when passing context to external programs.

Read fields in a Nu hook

Use get -o for stage-specific fields such as hook.outputDir that may be absent in other stages.

nu
use tola get-context

let ctx = get-context
let out = $ctx | get -o hook.outputDir
if $out != null {
  "Built with Tola\n" | save ($out | path join "build.txt")
}

Query context from an external shell hook

sh
"$TOLA_EXECUTABLE" nu @tola-scripts/context --json

Search this site

Use the arrow keys to move through results.

Type to search.