ddopson / underscore-cli

Command-line utility-belt for hacking JSON and Javascript.
Other
1.72k stars 83 forks source link

Output of result of compiling coffeescript breaks chaining #8

Closed spatten closed 12 years ago

spatten commented 12 years ago

A (contrived) example:

With Javascript:

# underscore process --data "[1,2,3,4]" --js "reject(data, function(n) {return n == 2})" | underscore pretty
[1, 3, 4]

With Coffee:

# underscore process --data "[1,2,3,4]" --coffee "reject(data, (n) -> n == 2)" | underscore pretty
Error while parsing STDIN in mode 'lax': Unexpected token :

The problem is that the output of the first command is:

# underscore process --data "[1,2,3,4]" --coffee "reject(data, (n) -> n == 2)"                              
JS:  
reject(data, function(n) {
  return n === 2;
});

[1, 3, 4]

And the output of the compilation result is blowing up the "underscore pretty" command.

It seems like the fix is to avoid outputting the compilation result by default and add a flag to show it for debugging.

Happy to submit a pull request if that's the desired behaviour.

ddopson commented 12 years ago

oops, that looks like a debug behavior that I left in by accident!

spatten commented 12 years ago

Ahh, cool. Makes sense :).

I'll let you fixed it up, then. Thanks!

ddopson commented 12 years ago

diff --git bin/underscore bin/underscore index af3486e..fd70e4d 100755 --- bin/underscore +++ bin/underscore @@ -809,7 +809,7 @@ function getUserFn_coffee(expression, args) { } try { var js = coffee.compile(code, {filename: 'expression', bare: true});