Skip to content

Commit 6c9d438

Browse files
committed
chore: enforce that site icons are .svg
1 parent 43cc544 commit 6c9d438

File tree

2 files changed

+48
-1
lines changed

2 files changed

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

0 commit comments

Comments
 (0)