2026-02-27 11:50:56 -05:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
|
|
set -euo pipefail
|
|
|
|
|
|
|
|
|
|
if [[ $# -ne 1 ]]; then
|
|
|
|
|
echo "usage: $0 <path-relative-to-site>" >&2
|
|
|
|
|
exit 2
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
script_dir=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
|
|
|
|
|
repo_root=$(cd "$script_dir/.." && pwd)
|
|
|
|
|
target=$1
|
|
|
|
|
|
|
|
|
|
output_file=$(mktemp)
|
|
|
|
|
trap 'rm -f "$output_file"' EXIT
|
|
|
|
|
|
|
|
|
|
if (
|
|
|
|
|
cd "$repo_root/site"
|
2026-03-05 22:32:18 +02:00
|
|
|
pnpm exec biome format --write --vcs-enabled=false "$target"
|
2026-02-27 11:50:56 -05:00
|
|
|
) >"$output_file" 2>&1; then
|
|
|
|
|
cat "$output_file"
|
|
|
|
|
exit 0
|
|
|
|
|
fi
|
|
|
|
|
status=$?
|
|
|
|
|
|
|
|
|
|
cat "$output_file" >&2
|
|
|
|
|
|
|
|
|
|
if [[ $status -eq 127 ]] || grep -q "Could not start dynamically linked executable" "$output_file" || grep -q "NixOS cannot run dynamically linked executables" "$output_file"; then
|
|
|
|
|
echo "WARNING: skipping biome format for '$target' because the biome binary is unavailable in this environment." >&2
|
|
|
|
|
exit 0
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
exit $status
|