Created
January 8, 2013 18:02
-
-
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.
This file contains hidden or 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/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