scripts/check-file-sizes.sh

d85099bc95bf1766aee990d94671dacda0c0686e
orgstar/scripts/check-file-sizes.sh history · blame · raw

12 lines · 650 bytes · executable

 1#!/bin/sh
 2# Lists hand-written Swift files over 1,000 lines and exits 1 when there are any.
 3# Generated files (scripts/update-char-fold.sh, scripts/update-highlight-queries.sh) are exempt.
 4# Usage: scripts/check-file-sizes.sh
 5set -eu
 6cd "$(dirname "$0")/.."
 7limit=1000
 8over="$(find Sources -name '*.swift' \
 9    ! -path 'Sources/OrgCore/Keymap/CharFold.swift' ! -path 'Sources/OrgHighlight/Queries.swift' \
10    -exec wc -l {} + | awk -v limit="$limit" '$2 != "total" && $1 > limit { printf "%6d %s\n", $1, $2 }')"
11[ -z "$over" ] || { echo "Swift files over $limit lines:"; echo "$over"; exit 1; }
12echo "No hand-written Swift file over $limit lines."