Skip to content

Instantly share code, notes, and snippets.

@cristianferrarig
Last active August 29, 2015 14:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cristianferrarig/dbf624bc37f54a04dd8a to your computer and use it in GitHub Desktop.
Save cristianferrarig/dbf624bc37f54a04dd8a to your computer and use it in GitHub Desktop.
Precompiler utility
#!/bin/bash
cd "$(dirname $0)"
dir=`pwd`
css_dir="$dir/_css/"
scss_dir="$dir/_scss/"
file_name=""
css_file=""
scss_file=""
if [ -z "$1" ]; then
./precompiler --help
exit
else
if [ $1 = "-?" -o $1 = "-h" -o $1 = "--help" ]; then
cat <<EOF
HeyHey | Sass precompiler utility
=================================
Usage: ./precompiler [option]
Common Options:
-?, -h, --help Show this help message.
-w, --watch Watch files in $scss_dir for changes.
-a, --all Precompile all files in $scss_dir.
NAME Precompile only the indicated file (without extension).
Have a nice day Sr.
EOF
exit
elif [ $1 = "-w" -o $1 = "--watch" ] ; then
sass --watch $scss_dir:$css_dir
elif [ $1 = "-a" -o $1 = "--all" ] ; then
printf -v css_dir_e "%q" $css_dir
printf -v scss_dir_e "%q" $scss_dir
for f in `find $scss_dir -name "[a-zA-Z0-9]*.scss"`; do
outf0="${f/$scss_dir/$css_dir_e}"
outf="${outf0%????}css"
sass $f:$outf
echo "sass $f:$outf"
done
else
file_name="$1"
css_file="$css_dir$file_name.css"
scss_file="$scss_dir$file_name.scss"
if [ -f $scss_file ]; then
sass $scss_file $css_file
else
echo "File $scss_file does not exist."
fi
fi
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment