squiggle/packages/squiggle-lang/lint.sh

42 lines
893 B
Bash
Raw Permalink Normal View History

#!/usr/bin/env bash
2022-04-11 04:05:23 +00:00
# Hat tip to @dfalling
# https://forum.rescript-lang.org/t/rescript-9-1-how-can-we-format-to-standard-out/1590/2?u=quinn-dougherty
errors=false
2022-04-11 13:35:25 +00:00
files=`ls src/rescript/**/**/*.res src/rescript/**/*.res src/rescript/*.res`
2022-04-11 04:05:23 +00:00
for file in $files
do
current=`cat $file`
2022-04-11 05:27:21 +00:00
linted=`echo "${current}" | rescript format -stdin .res`
2022-04-11 04:05:23 +00:00
diff=`diff <(echo $current) <(echo $linted)`
if [ ${#diff} -gt 0 ]
then
echo "ERROR: $file doesn't pass lint"
errors=true
fi
done
2022-04-11 13:35:25 +00:00
files=`ls src/rescript/**/**/*.resi src/rescript/**/*.resi` # src/rescript/*/resi
for file in $files
do
current=`cat $file`
linted=`echo "${current}" | rescript format -stdin .resi`
diff=`diff <(echo $current) <(echo $linted)`
if [ ${#diff} -gt 0 ]
then
echo "ERROR: $file doesn't pass lint"
errors=true
fi
done
2022-04-11 04:05:23 +00:00
if $errors
then
exit 1
else
2022-04-11 13:35:25 +00:00
echo "All files pass lint"
fi