-
Notifications
You must be signed in to change notification settings - Fork 1
/
check.sh
executable file
·70 lines (58 loc) · 1.35 KB
/
check.sh
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
#!/bin/bash
# Check if the required software is installed
function check_installed() {
if ! [ -x "$(command -v $1)" ]; then
echo "Error: $1 is not installed." >&2
exit 1
fi
}
check_installed "zola"
check_installed "cargo"
check_installed "stylelint"
check_installed "eslint"
check_installed "prettier"
# Check if zola has the version specified in zola_version file
zola_version=$(zola --version)
required_version=$(cat zola_version)
if [ "$zola_version" != "$required_version" ]; then
echo "Error: zola version is not $required_version" >&2
exit 1
fi
# Run formatters
echo
echo "RUSTFMT"
cargo fmt --all
echo
echo "PRETTIER"
prettier --write .
# Run checks
echo
echo "ZOLA"
zola build
ZOLA_SUCCESS=$?
echo
echo "CLIPPY"
cargo clippy --all-targets --all-features --fix --allow-dirty --allow-staged -- -D warnings
CLIPPY_SUCCESS=$?
echo
echo "TEST"
cargo test --all-targets --all-features --no-fail-fast
TEST_SUCCESS=$?
echo
echo "STYLELINT"
stylelint "**/*.{scss, css}" --fix
STYLELINT_SUCCESS=$?
echo
echo "ESLINT"
eslint "**/*.{js, ts}" --fix
ESLINT_SUCCESS=$?
SUCCESS=("$ZOLA_SUCCESS" "$CLIPPY_SUCCESS" "$TEST_SUCCESS" "$STYLELINT_SUCCESS" "$ESLINT_SUCCESS")
NAME=(Zola Clippy Test Stylelint Eslint)
echo
for i in "${!NAME[@]}"; do
if [ "${SUCCESS[$i]}" -eq 0 ]; then
echo "${NAME[$i]} OK"
else
echo "${NAME[$i]} FAILED"
fi
done