squiggle/packages/squiggle-lang/lint.sh

26 lines
571 B
Bash
Raw Normal View History

2022-04-11 04:05:23 +00:00
#!/bin/bash
# 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
2022-04-11 05:24:56 +00:00
files=`ls src/rescript/**/**/*.res src/rescript/**/*.res src/rescript/*.res`
2022-04-11 04:05:23 +00:00
errors=false
for file in $files
do
current=`cat $file`
2022-04-11 05:23:09 +00:00
linted=`echo "${current}" | ./node_modules/.bin/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
if $errors
then
exit 1
else
echo "All files pass linting!"
fi