Svelixir. Target
(svelixir v0.11.0)
Copy Markdown
A validated, absolute path to the project Svelixir is acting on.
This module exists because of failure F4. Mix.Project's compile_path/0
and build_path/0 re-expand a relative _build against the current working
directory on every call, so once the process changes directory they return
a path that does not exist — while Mix.Project's get!/0 keeps reporting
the scaffolder. The leak is asymmetric, nothing raises, and that is why it
hid.
A %Target{} captures the root once, absolutely, so no code in lib/ ever
asks Mix or the cwd which project it means.
The prose above is deliberately written without the literal tokens
Svelixir.BoundaryGuard bans: the guard is a substring scan over the whole
file, comments and docs included, so naming the hazard the obvious way would
make lib/ fail its own boundary test.
Summary
Functions
Builds a target from a path to a directory containing a mix.exs.
Resolves a project-relative path against the target root.
Types
@type t() :: %Svelixir.Target{root: Path.t()}
Functions
Builds a target from a path to a directory containing a mix.exs.
The mix.exs is never parsed or compiled — only its existence is checked —
so this succeeds against a project that cannot build.
Resolves a project-relative path against the target root.
Raises Svelixir.Target.EscapeError if the result would fall outside the
root, including for absolute inputs.