Skip to content

Commit

Permalink
Minify json files on build
Browse files Browse the repository at this point in the history
  • Loading branch information
NeRdTheNed committed Oct 11, 2023
1 parent 754c543 commit c8369e5
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/jekyll-gh-pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ jobs:
with:
source: ./
destination: ./_site
- name: Minify json files
run: bash jsonMinify.sh
- name: Upload artifact
uses: actions/upload-pages-artifact@v2

Expand Down
13 changes: 13 additions & 0 deletions jsonMinify.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
find ./_site/ \( -iname '*.json' \) -type f -print0 | while IFS= read -r -d $'\0' jsonFile; do
if [[ "$OSTYPE" == "darwin"* ]]; then
if ! command -v gsed &> /dev/null
then
echo "Please install GNU sed as gsed"
else
jq -c . < "$jsonFile" | gsed -z '$ s/\n$//' > "$jsonFile-tempOut"
fi
else
jq -c . < "$jsonFile" | sed -z '$ s/\n$//' > "$jsonFile-tempOut"
fi
mv "$jsonFile-tempOut" "$jsonFile"
done

0 comments on commit c8369e5

Please sign in to comment.