more progress with the lexer, perhaps it's done

This commit is contained in:
Jeremy Ashkenas
2010-01-30 15:56:40 -05:00
parent f19360c6b9
commit babeebcc1a
6 changed files with 247 additions and 121 deletions

View File

@@ -23,7 +23,7 @@
};
// Compile a list of CoffeeScript files on disk.
exports.compile_files = function compile_files(paths, callback) {
var coffee, js;
var coffee, exit_ran, js;
js = '';
coffee = process.createChildProcess(compiler, ['--print'].concat(paths));
coffee.addListener('output', function(results) {
@@ -31,7 +31,13 @@
return js += results;
}
});
// NB: we have to add a mutex to make sure it doesn't get called twice.
exit_ran = false;
return coffee.addListener('exit', function() {
if (exit_ran) {
return null;
}
exit_ran = true;
return callback(js);
});
};