Skip to content

Commit bb1f3e2

Browse files
committed
Adapt formatting scripts to work with Ubuntu installs of fd.
1 parent 5809530 commit bb1f3e2

File tree

2 files changed

+29
-7
lines changed

2 files changed

+29
-7
lines changed

scripts/ci/run-cabal-fmt.sh

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,16 @@
22

33
set -euo pipefail
44

5-
fd --full-path "$(pwd)/(ouroboros-consensus|sop-extras|strict-sop-core)" -e cabal -x cabal-fmt -i
5+
# First, try to find the 'fd' command
6+
fdcmd="fd"
7+
if ! command -v "$fdcmd" &> /dev/null; then
8+
# In Ubuntu systems the fd command is called fdfind.
9+
# If 'fd' is not found, try 'fdfind'
10+
fdcmd="fdfind"
11+
if ! command -v "$fdcmd" &> /dev/null; then
12+
echo "Error: Neither 'fd' nor 'fdfind' command found." >&2
13+
exit 1
14+
fi
15+
fi
16+
17+
$fdcmd --full-path "$(pwd)/(ouroboros-consensus|sop-extras|strict-sop-core)" -e cabal -x cabal-fmt -i

scripts/ci/run-stylish.sh

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,22 @@ stylish-haskell --defaults | diff - ./.stylish-haskell.yaml | grep -E "^>.*[[:al
77
printf "\nFormatting haskell files...\n"
88

99
export LC_ALL=C.UTF-8
10-
fd --full-path "$(pwd)/(ouroboros-consensus|scripts|sop-extras|strict-sop-core)" \
11-
--extension hs \
12-
--exclude Setup.hs \
13-
--exclude ouroboros-consensus-cardano/app/DBAnalyser/Parsers.hs \
14-
--exec-batch stylish-haskell -c .stylish-haskell.yaml -i
15-
10+
# First, try to find the 'fd' command
11+
fdcmd="fd"
12+
if ! command -v "$fdcmd" &> /dev/null; then
13+
# In Ubuntu systems the fd command is called fdfind.
14+
# If 'fd' is not found, try 'fdfind'
15+
fdcmd="fdfind"
16+
if ! command -v "$fdcmd" &> /dev/null; then
17+
echo "Error: Neither 'fd' nor 'fdfind' command found." >&2
18+
exit 1
19+
fi
20+
fi
21+
$fdcmd --full-path "$(pwd)/(ouroboros-consensus|scripts|sop-extras|strict-sop-core)" \
22+
--extension hs \
23+
--exclude Setup.hs \
24+
--exclude ouroboros-consensus-cardano/app/DBAnalyser/Parsers.hs \
25+
--exec-batch stylish-haskell -c .stylish-haskell.yaml -i
1626

1727
# We don't want these deprecation warnings to be removed accidentally
1828
grep "#if __GLASGOW_HASKELL__ < 900

0 commit comments

Comments
 (0)