Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions scripts/lint-shell-templates.sh
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,11 @@ EOF
chezmoi_config="$tmpdir/chezmoi.toml"

# Render a chezmoi template to stdout using the non-interactive config.
# --source "$repo_root" ensures include directives resolve against the
# repository's source tree rather than the default chezmoi source directory.
render_template() {
local tmpl="$1"
chezmoi execute-template --config "$chezmoi_config" < "$tmpl"
chezmoi execute-template --config "$chezmoi_config" --source "$repo_root" < "$tmpl"
}

# Lint a rendered bash template with shellcheck.
Expand All @@ -72,7 +74,8 @@ lint_sh_template() {
# Lint a rendered zsh template with zsh -n (shellcheck does not support zsh).
lint_zsh_template() {
local tmpl="$1"
local rendered="$tmpdir/$(basename "$tmpl" .tmpl)"
local rendered
rendered="$tmpdir/$(basename "$tmpl" .tmpl)"
echo "=== $tmpl (zsh) ==="
render_template "$tmpl" > "$rendered"
if command -v zsh >/dev/null 2>&1; then
Expand Down