Created
April 24, 2012 21:15
-
-
Save shesek/2483880 to your computer and use it in GitHub Desktop.
Bash script for quickly debugging CoffeeScript 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 | |
[ -z $3 ] && AROUND=2 || AROUND=$3 | |
coffee -cp $1 | nl -b a | perl -pe "\$_ = \"\033[1;29m\$_\033[0m\" if (\$. == $2)" | head -n $(($2+$AROUND)) | tail -n $(($AROUND * 2 + 1)) | |
# Usage: dcoffee path/to/file.coffee <LINE NUMBER> [NUMBER OF LINES BEFORE/AFTER] | |
# A tiny bash script for finding a line in the compiled JavaScript with some context around it, | |
# useful to quickly check where errors in compiled JavaScript are coming from. | |
# https://github.com/jashkenas/coffee-script/issues/558 FTW | |
# Example: | |
# $ dcoffee util/index.coffee 7 | |
# 5 isArray = require('underscore').isArray; | |
# 6 | |
# 7 exports.uncurryThis = uncurryThis = Function.prototype.bind.bind(Function.prototype.call); | |
# 8 | |
# 9 exports.curryThis = curryThis = function(fn) { | |
# $ dcoffee util/index.coffee 7 1 | |
# 6 | |
# 7 exports.uncurryThis = uncurryThis = Function.prototype.bind.bind(Function.prototype.call); | |
# 8 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment