camertron / esprima-rb

Ruby wrapper around the Esprima static code analyzer for JavaScript.
Apache License 2.0
8 stars 4 forks source link

Isn't happy working with Node.js #5

Open presidentbeef opened 11 years ago

presidentbeef commented 11 years ago

Sadness:

1.9.3-p392 :001 > require 'esprima'
 => true
1.9.3-p392 :002 > Esprima::Parser.new
TypeError: nil is not a symbol
    from /Users/collins/.rvm/gems/ruby-1.9.3-p392@coffeebreak/gems/esprima-1.4.2/lib/esprima.rb:30:in `instance_variable_get'
    from /Users/collins/.rvm/gems/ruby-1.9.3-p392@coffeebreak/gems/esprima-1.4.2/lib/esprima.rb:30:in `new_context'
    from /Users/collins/.rvm/gems/ruby-1.9.3-p392@coffeebreak/gems/esprima-1.4.2/lib/esprima.rb:20:in `new_environment'
    from /Users/collins/.rvm/gems/ruby-1.9.3-p392@coffeebreak/gems/esprima-1.4.2/lib/esprima/parser.rb:6:in `initialize'
    from (irb):2:in `new'
    from (irb):2
    from /Users/collins/.rvm/rubies/ruby-1.9.3-p392/bin/irb:16:in `<main>'

The context seems to not include the expected stuff:

1.9.3-p392 :001 > require 'execjs'
 => true
1.9.3-p392 :002 > ExecJS.runtime.class::Context.new(nil)
 => #<ExecJS::ExternalRuntime::Context:0x007fcdaa328140 @runtime=nil, @source="">
1.9.3-p392 :003 > ExecJS.runtime
 => #<ExecJS::ExternalRuntime:0x007fcda988cf38 @name="Node.js (V8)", @command=["nodejs", "node"], @runner_path="/Users/collins/.rvm/gems/ruby-1.9.3-p392@coffeebreak/gems/execjs-1.4.0/lib/execjs/support/node_runner.js", @test_args=nil, @test_match=nil, @encoding="UTF-8", @deprecated=false, @binary="node">

:saxophone:

camertron commented 11 years ago

Hey @presidentbeef I haven't had time to look into this issue, sorry about that. Probably won't have much time in the future either - any ideas?

presidentbeef commented 11 years ago

I'll take a look into this. Looks like Esprima is pulling the context out of ExecJS and passing it to CommonJS. But when ExecJS loads node.js, it doesn't have a "context" because it's an ExternalRuntime. Not sure this can be resolved.

camertron commented 11 years ago

Yeah, I fiddled with this a bit as well and couldn't figure it out. I believe there are a few similar issues filed against ExecJS, but no satisfactory answers yet :(