Last active
August 29, 2015 13:58
-
-
Save HectorAE/9995888 to your computer and use it in GitHub Desktop.
Use stylish-haskell on many files at once.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/sh | |
# Script that automatically runs stylish-haskell on the given file | |
# or every file in the given directory and its subdirectories. | |
# Written by Hector A Escobedo | |
if ! hash sponge 2> /dev/null | |
then | |
echo "The sponge dependency from moreutils is missing." | |
exit 1 | |
fi | |
if ! hash stylish-haskell 2> /dev/null | |
then | |
echo "The stylish-haskell dependency is missing." | |
exit 1 | |
fi | |
if [ -d "$1" ] | |
then | |
for f in `find $1 -type f` | |
do | |
stylish-haskell $f | sponge $f | |
done | |
elif [ -f "$1" ] | |
then | |
stylish-haskell $1 | sponge $1 | |
else | |
echo "Usage: hs-stylize DIRECTORY/FILE" | |
exit 2 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment