Skip to content

Instantly share code, notes, and snippets.

@avilaj
Created May 12, 2013 04:04
Show Gist options
  • Save avilaj/5562379 to your computer and use it in GitHub Desktop.
Save avilaj/5562379 to your computer and use it in GitHub Desktop.
#! /bin/bash
# Vigila cambios en archivos coffe y stylus y los compila
# Se debe iniciar en el directorio padre de las dos carpetas
# Osea si el archivo se encuentra en proyecto/estaticos/coffe
# Se debe iniciar en proyecto/estaticos/
function notify {
notify-send -i applications-development -t 500 "Compilado!" $1
echo $1
}
compile(){
# DIRECTORIOS
if [ -z $1 ]
then
DIRECTORIO=/var/www/laravel/php
else
DIRECTORIO=${PWD}
fi
JS=$DIRECTORIO/js
CSS=$DIRECTORIO/css
STYLUS=$DIRECTORIO/stylus
COFFEE=$DIRECTORIO/coffee
notify-send -i applications-development -t 500 "Observando directorio" $DIRECTORIO
while FILE=$(inotifywait -rq --format '%f' -e create -e modify $DIRECTORIO);
do
if [[ $FILE =~ .*.coffee ]]
then
MSG=$(coffee -o $JS/ -cbl $COFFEE/$FILE)
notify "$FILE"
elif [[ $FILE =~ .*.styl ]]
then
MSG=$(stylus $STYLUS/$FILE -o $CSS/)
notify "$FILE"
fi
sleep 1
done
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment