Skip to content

Commit

Permalink
Merge pull request #465 from IntersectMBO/wenkokke/fix-format-stylish2
Browse files Browse the repository at this point in the history
Speed up `scripts/format-stylish.sh`
  • Loading branch information
jorisdral authored Nov 13, 2024
2 parents 006c430 + 30afc5d commit 10e6811
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 5 deletions.
3 changes: 3 additions & 0 deletions .stylish-haskell.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -511,3 +511,6 @@ language_extensions:
# We run stylish from the root of the repo which is a project so this flag
# doesn't apply
cabal: false

# Return an exit failure on format.
exit_code: error_on_format
2 changes: 1 addition & 1 deletion scripts/format-cabal.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ fi
# Check Cabal files with cabal-fmt
echo "Formatting Cabal source files with cabal-fmt version ${cabal_fmt_required_version}"
# shellcheck disable=SC2016
if ! git ls-files --exclude-standard --no-deleted --deduplicate '*.cabal' | xargs -L 1 sh -c 'echo "$0" && cabal-fmt -i "$0"'; then
if ! git ls-files --exclude-standard --no-deleted --deduplicate '*.cabal' | xargs -L 1 sh -c 'echo "$0" && cabal-fmt -c "$0" 2>/dev/null || (cabal-fmt -i "$0" && exit 1)'; then
exit 1
fi
2 changes: 1 addition & 1 deletion scripts/format-stylish.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ fi
# Check Haskell files with stylish-haskell
echo "Formatting Haskell source files with stylish-haskell version ${stylish_haskell_required_version}"
# shellcheck disable=SC2016
if ! git ls-files --exclude-standard --no-deleted --deduplicate '*.hs' | xargs -L 1 sh -c 'echo "$0" && stylish-haskell -i -c .stylish-haskell.yaml "$0"'; then
if ! git ls-files --exclude-standard --no-deleted --deduplicate '*.hs' | xargs -L 50 stylish-haskell -i -c .stylish-haskell.yaml; then
exit 1
fi
6 changes: 3 additions & 3 deletions scripts/pre-commit.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@ if [ ! "${unstaged_cabal_files}" = "" ]; then
fi

# Run various checks and formatters
./scripts/check-cabal.sh
./scripts/format-cabal.sh
./scripts/format-stylish.sh
./scripts/check-cabal.sh || exit 1
./scripts/format-cabal.sh || exit 1
./scripts/format-stylish.sh || exit 1

0 comments on commit 10e6811

Please sign in to comment.