Created
February 8, 2011 18:55
-
-
Save thelinuxlich/816977 to your computer and use it in GitHub Desktop.
This shellscript watches coffee files for changes and compiles them and runs docco after
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 | |
# use my inotify-tools fork at https://github.com/thelinuxlich/inotify-tools | |
# use my docco fork if you want to generate php documentation(npm install thelinuxlich-docco) | |
while output=`inotifywait -r -e create -e close_write -e modify --format '%w %f' --include ".*\.(coffee|php)$" /srv/www/htdocs/php/`; do | |
DIR=${output%% *} | |
DOCDIR=${DIR/php\//php\/docs/} | |
FILE=${output#* } | |
echo "Detected a change in ${DIR}${FILE} ..." >> /srv/www/htdocs/php/logs/watcher.log | |
if [[ $FILE == *.coffee* ]] | |
then | |
COFFEEDIR="${DIR}${FILE}" | |
JSDIR="${DIR/coffee/js/}" | |
mkdir -p $JSDIR | |
echo "Compiling JS from ${COFFEEDIR} to ${JSDIR}..." >> /srv/www/htdocs/php/logs/watcher.log | |
coffee -o $JSDIR -c ${COFFEEDIR} 2>> /srv/www/htdocs/php/logs/watcher.log | |
fi; | |
DOCCOFILE=${DIR}doc_${FILE} | |
cp ${DIR}${FILE} ${DOCCOFILE} | |
echo "Generating documentation of ${DOCCOFILE}..." >> /srv/www/htdocs/php/logs/watcher.log | |
if [[ `file -i ${DIR}${FILE}` != *utf-8* ]] | |
then | |
iconv --from-code=ISO-8859-1 --to-code=UTF-8 ${DIR}${FILE} > $DOCCOFILE | |
fi | |
docco ${DOCCOFILE} >> /srv/www/htdocs/php/logs/watcher.log | |
rm -f $DOCCOFILE | |
mkdir -p $DOCDIR | |
mv -f /srv/www/htdocs/php/sh/docs/* $DOCDIR | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment