-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcheck
More file actions
executable file
·86 lines (65 loc) · 1.76 KB
/
Copy pathcheck
File metadata and controls
executable file
·86 lines (65 loc) · 1.76 KB
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#!/usr/bin/env bash
set -euo pipefail
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
die() {
printf 'error: %s\n' "$*" >&2
exit 1
}
if [[ "$#" -ne 0 ]]; then
die "check does not accept arguments"
fi
for required_command in bash git shellcheck shfmt vim zsh; do
if ! command -v "$required_command" >/dev/null 2>&1; then
die "$required_command is required; run the package installer first"
fi
done
cd "$ROOT_DIR"
bash_scripts=(
bootstrap
check
install-packages
linux/bootstrap
linux/install-packages
macos-defaults.sh
)
zsh_configs=(
.zprofile
.zshrc
linux/.zshrc
)
echo "Checking Bash syntax..."
for script in "${bash_scripts[@]}"; do
bash -n "$script"
done
echo "Checking zsh syntax..."
for config in "${zsh_configs[@]}"; do
zsh -n "$config"
done
echo "Running ShellCheck..."
shellcheck "${bash_scripts[@]}"
echo "Checking Bash formatting..."
shfmt -d -i 2 -ci "${bash_scripts[@]}"
echo "Parsing Git configuration..."
git config --file git/config --list >/dev/null
git config --file linux/git/config --list >/dev/null
echo "Loading Vim configuration..."
vim -Nu .vimrc -n -es -i NONE '+quitall'
if [[ "$(uname -s)" == "Darwin" ]]; then
GHOSTTY_BIN="/Applications/Ghostty.app/Contents/MacOS/ghostty"
if [[ ! -x "$GHOSTTY_BIN" ]]; then
die "Ghostty is required; run the package installer first"
fi
echo "Validating Ghostty configuration..."
"$GHOSTTY_BIN" +validate-config --config-file=ghostty/config.ghostty
fi
echo "Checking whitespace..."
grep_status=0
git grep -nI -E '[[:blank:]]+$' || grep_status=$?
case "$grep_status" in
0) die "tracked files contain trailing whitespace" ;;
1) ;;
*) die "git grep failed while checking whitespace" ;;
esac
git diff --check
git diff --cached --check
echo "All checks passed."