Skip to content

Commit 10e6811

Browse files
authored
Merge pull request #465 from IntersectMBO/wenkokke/fix-format-stylish2
Speed up `scripts/format-stylish.sh`
2 parents 006c430 + 30afc5d commit 10e6811

File tree

4 files changed

+8
-5
lines changed

4 files changed

+8
-5
lines changed

.stylish-haskell.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -511,3 +511,6 @@ language_extensions:
511511
# We run stylish from the root of the repo which is a project so this flag
512512
# doesn't apply
513513
cabal: false
514+
515+
# Return an exit failure on format.
516+
exit_code: error_on_format

scripts/format-cabal.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,6 @@ fi
1818
# Check Cabal files with cabal-fmt
1919
echo "Formatting Cabal source files with cabal-fmt version ${cabal_fmt_required_version}"
2020
# shellcheck disable=SC2016
21-
if ! git ls-files --exclude-standard --no-deleted --deduplicate '*.cabal' | xargs -L 1 sh -c 'echo "$0" && cabal-fmt -i "$0"'; then
21+
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
2222
exit 1
2323
fi

scripts/format-stylish.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,6 @@ fi
1818
# Check Haskell files with stylish-haskell
1919
echo "Formatting Haskell source files with stylish-haskell version ${stylish_haskell_required_version}"
2020
# shellcheck disable=SC2016
21-
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
21+
if ! git ls-files --exclude-standard --no-deleted --deduplicate '*.hs' | xargs -L 50 stylish-haskell -i -c .stylish-haskell.yaml; then
2222
exit 1
2323
fi

scripts/pre-commit.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,6 @@ if [ ! "${unstaged_cabal_files}" = "" ]; then
2222
fi
2323

2424
# Run various checks and formatters
25-
./scripts/check-cabal.sh
26-
./scripts/format-cabal.sh
27-
./scripts/format-stylish.sh
25+
./scripts/check-cabal.sh || exit 1
26+
./scripts/format-cabal.sh || exit 1
27+
./scripts/format-stylish.sh || exit 1

0 commit comments

Comments
 (0)