forked from coder/coder
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbiome_format.sh
More file actions
executable file
·33 lines (25 loc) · 794 Bytes
/
Copy pathbiome_format.sh
File metadata and controls
executable file
·33 lines (25 loc) · 794 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/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"
pnpm exec biome format --write --vcs-enabled=false "$target"
) >"$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