module

Hace

Constants

DEPRECATED_ENV_WARNED = Set(String).new

Environment variable names that already produced a deprecation warning (${NAME} expansion, brace-less $NAME in non-command fields), so each is reported at most once per run.

ENVIRONMENT = {} of String => String
FAIL_FAST_SHELLS = ["sh", "bash", "zsh", "dash", "ash", "ksh", "mksh"] of ::String

Shells that understand POSIX fail-fast (-e). When a task or Hacefile selects one of these shells without explicit arguments, hace runs the commands with "-e -c" so multi-command tasks stop at the first failure, matching the default /bin/sh behavior. Other shells (python, cmd.exe, ...) only get the script passed via -c.

RECIPE_STAMP_DIR = ".hace"

Recipe stamps make the rendered recipe part of the staleness model.

Croupier only considers missing outputs, input file hashes and upstream staleness, so editing a task's commands in the Hacefile would never trigger a rebuild. To fix that, every task gets an extra input: a small file whose content is the SHA1 of its commands, shell and working directory. When the recipe changes, the stamp content changes, and the regular input-hash comparison marks the task stale.

TASKS_WITH_CLI_ARGS = Set(String).new

Track which tasks explicitly use CLI_ARGS (detected before Crinja expansion)

VARIABLES = {} of String => Value
VERSION = {{ (`shards version /tmp/tmp.mCgego/src/src`).chomp.stringify }}

Class methods

env_namespace

Snapshot the merged environment view as template variables, backing the env namespace ({{ env.NAME }}). It matches what task shells see for $NAME: process environment (including dotenv) plus env: overrides.

Source
expand_env_in_value(value : Hace::Value) : Hace::Value

Expand the deprecated ${ENV_VAR} references inside a value and everything nested in it, leaving non-string values untouched. Warns when a brace-less $ENV_VAR reference would have expanded before (only names that resolve in the merged environment, to keep noise down).

Source
expand_env_vars(str : String) : String

Expand the deprecated braced ${ENV_VAR} references from the merged environment view. Actual substitutions log a deprecation warning, once per variable name per run; undefined references stay literal (matching both the old behavior and post-removal shell passthrough).

Source
expand_glob(str : String) : Array(String)
Source
expand_string(str : String, variables = Hace::VARIABLES) : String
Source
from_yaml_any(any : YAML::Any) : Hace::Value

Convert a parsed YAML node into the typed Value representation. This is the single place where YAML::Any is allowed to exist.

Source
inject_cli_args(cli_args : Array(String))

Inject CLI_ARGS and CLI_ARGS_LIST into VARIABLES for template expansion

Source
load_dotenv(dotenv_file = nil)
Source
recipe_stamp_path(task_name : String) : String
Source
reset_state

Clear the module-level mutable state (VARIABLES, ENVIRONMENT, the CLI_ARGS tracking set and the env-deprecation warning set). Intended for use between test scenarios so that values injected by one run (CLI_ARGS, Hacefile variables, env entries) do not leak into the next. Mirrors Croupier::TaskManager.cleanup.

Source
stamp_recipe(task_name : String, signature : String) : String

Record the current recipe signature for task_name and return the stamp path. Writing is skipped when the content is unchanged so the file's mtime stays stable (mtime-based staleness modes would otherwise see it as modified on every run). Failures degrade gracefully: the returned path then simply does not exist, which scan_inputs skips, giving the old behavior without recipe sensitivity.

Source
to_crinja_value(value : Hace::Value) : Crinja::Value
Source
to_crinja_variables(hash : Hash(String, Value)) : Crinja::Variables

Convert a Hash(String, Value) to Crinja::Variables

Source
warn_braceless_env_ref(str : String)

Warn about brace-less $WORD references in non-command fields: hace no longer expands them, so a value like "$HOME" stays literal. Only names that resolve in the merged environment warn, since only those could have relied on the old expansion.

Source

Nested types