Skip to content

Commit

Permalink
ci: lint SVG files
Browse files Browse the repository at this point in the history
  • Loading branch information
sethfischer committed Jun 11, 2021
1 parent a58a097 commit a398ffe
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,8 @@ jobs:
run: |
sudo apt-get -y install clang-format
make lint-c
- name: Lint SVG files
run: |
sudo -y apt-get install scour
make lint-svg
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.PHONY: lint
lint: lint-c
lint: lint-c lint-svg

.PHONY: lint-c
lint-c:
.PHONY: lint-c lint-svg
lint-c lint-svg:
./$@.sh
21 changes: 21 additions & 0 deletions lint-svg.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/usr/bin/env bash

shopt -s globstar

exit_code=0

while IFS= read -r -d $'\0' filename; do
if [ -f "$filename" ]; then
echo "Check formatting of ${filename}"
diff "$filename" <(scour --quiet -i "$filename" --indent=space --nindent=2 --protect-ids-noninkscape --enable-id-stripping) 1>&2
# shellcheck disable=SC2181
if [ $? -ne 0 ]; then
exit_code=1
echo "Fail"
else
echo "Pass"
fi
fi
done < <(git ls-files -z -- "./**.svg")

exit $exit_code

0 comments on commit a398ffe

Please sign in to comment.