merging in matehat's registerExtension patch for direct-requires of CoffeeScript.

This commit is contained in:
Jeremy Ashkenas
2010-03-15 23:03:30 -07:00
5 changed files with 15 additions and 4 deletions

View File

@@ -13,6 +13,7 @@ if process?
parser: require('./parser').parser
helpers: require('./helpers').helpers
helpers.extend global, require './nodes'
require.registerExtension '.coffee', (content) -> compile content if require.registerExtension
else
this.exports: this.CoffeeScript: {}
Lexer: this.Lexer
@@ -26,7 +27,7 @@ lexer: new Lexer()
# Compile a string of CoffeeScript code to JavaScript, using the Coffee/Jison
# compiler.
exports.compile: (code, options) ->
exports.compile: compile: (code, options) ->
options ||= {}
try
(parser.parse lexer.tokenize code).compile options