2

I am trying to get the coffeescript compiler working with RingoJS (we're a Java shop...)

I have had some success - https://github.com/jashkenas/coffee-script/wiki/Using-CS-with-Java-Rhino

Now I am trying to get the coffee-script/command stuff ( https://github.com/jashkenas/coffee-script/blob/master/lib/coffee-script/command.js ) to work rather than re-doing it, but its failing on these lines:

CoffeeScript = require('./coffee-script');

_ref = require('child_process'), spawn = _ref.spawn, exec = _ref.exec;

EventEmitter = require('events').EventEmitter;

helpers.extend(CoffeeScript, new EventEmitter);

// fails here - EventEmitter is undefined and so the extend fails.

I have tried writing an adapter "events.js" to turn the ringojs/events into what its expecting, but my JS skills or lack of them are failing me.

This is what I have:

(function() {
    require("ringo/events");
    var events = { };
    events['EventEmitter'] = EventEmitter;
    return events;
}).call(this);

But EventEmitter is still undefined here - I'd expect it to be available due to the exports.EventEmitter line in ringojs/events, but obviously not...

Any thoughts/tips on where I am going wrong.

Thanks in advance, Chris

Chris Kimpton
  • 5,546
  • 6
  • 45
  • 72
  • 1
    in the last code example: `require("ringo/events")` will not add EventEmitter to the function scope. In the first example you are doing it right: `EventEmitter = require('events').EventEmitter` or even nicer: `var {EventEmitter} = require('events')`. – oberhamsi Jun 01 '12 at 10:30

0 Answers0