Skip to content

Instantly share code, notes, and snippets.

@shanna
Created July 5, 2012 23:59
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 shanna/3057217 to your computer and use it in GitHub Desktop.
Save shanna/3057217 to your computer and use it in GitHub Desktop.
Watch and compile JS and CSS.
templates:
cd web/templates && haml-coffee -i . -n this.nd.templates -o ../js/nd-templates.js
css:
cd web/css && recess nd.less --compile > ../../public/nd.css
app:
cd web/app && coffee -cj ../js/nd.js nd.coffee
js:
cd web/js && cat moment.js underscore.js backbone.js nd-templates.js nd.js | uglifyjs -nc -o ../../public/nd.js
watch:
./bin/nd-watch
install:
mkdir -p web/templates web/css web/app web/js public
sudo npm install -g recess coffee-script uglify-js haml-coffee
all: css templates app js
#!/bin/bash
root=$(readlink -f $(dirname $0)/..)
cd $root
inotifywait -qrm --format '%w%f' -e close_write -e delete "$root" | while read file; do
# Ignore dot directories.
[[ $(dirname $file) =~ /\. ]] && continue
# Ignore dotfiles.
[[ $(basename $file) =~ ^\.|\.lock$ ]] && continue
file="${file#$root/}"
if [[ $file =~ web/templates/.*\.haml\.coffee ]]; then
echo $file
make templates > /dev/null
elif [[ $file =~ web/css/.*\.less ]]; then
echo $file
make css > /dev/null
elif [[ $file =~ web/app/.*\.coffee ]]; then
echo $file
make app > /dev/null
elif [[ $file =~ web/js/.*\.js ]]; then
echo $file
make js > /dev/null
elif [[ $file =~ public/ ]]; then
# TODO: Not quite true, a delete in public/ would trigger this.
echo "> $file"
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment