Skip to content

Instantly share code, notes, and snippets.

@shesek
Created April 24, 2012 21:15
Show Gist options
  • Save shesek/2483880 to your computer and use it in GitHub Desktop.
Save shesek/2483880 to your computer and use it in GitHub Desktop.
Bash script for quickly debugging CoffeeScript line numbers
#!/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