Skip to content

Instantly share code, notes, and snippets.

@bxt
Last active August 29, 2015 14:00
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 bxt/11018611 to your computer and use it in GitHub Desktop.
Save bxt/11018611 to your computer and use it in GitHub Desktop.
Build coffeescript file
#!/bin/bash
if [ $# -ne 1 ]; then
echo "Usage: $(basename $0) COFFEEFILE"
echo " - Compile COFFEEFILE into a minified javascript on file changes."
exit 64
fi
COFFEE=coffee
UGLIFYJS=uglifyjs
WARNBROKEN="tput bel"
echo Watching $1 for changes...
while inotifywait -q --format "%T: %w changed, building..." --timefmt "%c" -e close_write "$1"; do
$COFFEE -c -m "$1" &&
$UGLIFYJS "${1%.coffee}.js" \
--source-map "${1%.coffee}.min.map" \
--in-source-map "${1%.coffee}.map" \
-o "${1%.coffee}.min.js" ||
$WARNBROKEN
echo -ne " done.\033[0K\r"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment