Skip to content

Instantly share code, notes, and snippets.

@rbergman
Created January 8, 2013 18:02
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rbergman/4486199 to your computer and use it in GitHub Desktop.
Save rbergman/4486199 to your computer and use it in GitHub Desktop.
Compile CoffeeScript files to JavaScript and send the result to stdout, with optional line numbers.
#!/bin/bash
if [ "$#" == "0" ]; then
echo "Usage: ccs [-n] file1 ... fileN"
echo "Compiles CoffeeScript files to JavaScript and emits the result to stdout."
echo " -n prepend line numbers"
exit 1
fi
if [ "$1" == "-n" ]; then
NL=1
shift
fi
for file in $*; do
if [ "$#" -gt "1" ]; then echo "### $file ###"; fi
coffee -c $file 2> /dev/null
out="${file%%.*}.js"
if [ "$NL" == "1" ]; then
nl -ba $out
else
cat $out
fi
rm $out
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment