Skip to content

Commit 78203e1

Browse files
committed
chore: enforce that site icons are .svg
1 parent 9833cd3 commit 78203e1

File tree

2 files changed

+50
-1
lines changed

2 files changed

+50
-1
lines changed

Makefile

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -410,9 +410,14 @@ else
410410
endif
411411
.PHONY: fmt/shfmt
412412

413-
lint: lint/shellcheck lint/go lint/ts lint/helm
413+
lint: lint/shellcheck lint/go lint/ts lint/helm lint/site-icons
414414
.PHONY: lint
415415

416+
lint/site-icons:
417+
cd site/static/icons
418+
419+
.PHONY: lint/site-icons
420+
416421
lint/ts:
417422
cd site
418423
yarn && yarn lint

scripts/check_site_icons.sh

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#!/bin/bash
2+
3+
set -euo pipefail
4+
# shellcheck source=scripts/lib.sh
5+
source "$(dirname "${BASH_SOURCE[0]}")/lib.sh"
6+
cdroot
7+
8+
cd site/static/icon
9+
10+
# These exceptions are here for backwards compatibility. All new icons should
11+
# be SVG to minimize the size of our repo and our bundle.
12+
exceptions=(
13+
"aws.png"
14+
"azure.png"
15+
"docker.png"
16+
"do.png"
17+
"gcp.png"
18+
"k8s.png"
19+
)
20+
21+
function is_exception() {
22+
local value="$1"
23+
shift
24+
for item; do
25+
[[ "$item" == "$value" ]] && return 0
26+
done
27+
return 1
28+
}
29+
30+
for file in *; do
31+
# Extract filename
32+
filename=$(basename -- "$file")
33+
34+
# Check if the file is in the exception list
35+
if is_exception "$filename" "${exceptions[@]}"; then
36+
continue
37+
fi
38+
39+
# If not an exception, check if it's an svg file
40+
if [[ "$file" != *.svg ]]; then
41+
echo "Found a non-svg file not in exception list: $file"
42+
exit 1
43+
fi
44+
done

0 commit comments

Comments
 (0)