ddopson / underscore-cli

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

Error while evaluating user expression as JavaScript: console is not defined #13

Closed dmnd closed 11 years ago

dmnd commented 12 years ago

I get an error running an example in the help:

$ node -v
v0.8.11

$ npm -v
1.1.62

$ underscore --version
0.2.10

$ echo '{"foo":1, "bar":2}' | underscore map -q 'console.log("key = ", key)'
Error while evaluating user expression 'console.log("key = ", key)' as JavaScript: console is not defined

$ echo 'console.log("hi")' | node
hi
ddopson commented 11 years ago

Is that the "Angry Sun" from Mario 3? Awesome Icon.

weird. Hmmm. that seems like a bug. I'll take a look

ddopson commented 11 years ago

Looks like this happened due my misguided attempt to isolate the JS eval context from the global scope where program vars are declared.

ddopson commented 11 years ago

Fixed this with https://github.com/ddopson/underscore-cli/commit/16c44e1af45dec4b8b782435a8a25a0cbaf7f4a1

Thanks for the bug report.

ddopson commented 11 years ago

Also pushed v0.2.15 with that fix :)

dmnd commented 11 years ago

Thanks for fixing, and yeah, my angry sun is from Mario 3 :)