mirror of
https://github.com/jashkenas/coffeescript.git
synced 2026-02-16 18:44:56 -05:00
Added an extension on node's 'require' module so it can import .coffee module and added some tests to make sure it works.
This commit is contained in:
2
Cakefile
2
Cakefile
@@ -68,6 +68,8 @@ task 'doc:underscore', 'rebuild the Underscore.coffee documentation page', ->
|
|||||||
|
|
||||||
task 'test', 'run the CoffeeScript language test suite', ->
|
task 'test', 'run the CoffeeScript language test suite', ->
|
||||||
process.mixin require 'assert'
|
process.mixin require 'assert'
|
||||||
|
require.paths.unshift './test'
|
||||||
|
|
||||||
test_count: 0
|
test_count: 0
|
||||||
start_time: new Date()
|
start_time: new Date()
|
||||||
[original_ok, original_throws]: [ok, throws]
|
[original_ok, original_throws]: [ok, throws]
|
||||||
|
|||||||
@@ -17,6 +17,9 @@
|
|||||||
Lexer = this.Lexer;
|
Lexer = this.Lexer;
|
||||||
parser = this.parser;
|
parser = this.parser;
|
||||||
}
|
}
|
||||||
|
require.registerExtension('.coffee', function(content) {
|
||||||
|
return require('coffee-script').compile(content);
|
||||||
|
});
|
||||||
// The current CoffeeScript version number.
|
// The current CoffeeScript version number.
|
||||||
exports.VERSION = '0.5.5';
|
exports.VERSION = '0.5.5';
|
||||||
// Instantiate a Lexer for our use here.
|
// Instantiate a Lexer for our use here.
|
||||||
|
|||||||
@@ -17,6 +17,9 @@ else
|
|||||||
Lexer: this.Lexer
|
Lexer: this.Lexer
|
||||||
parser: this.parser
|
parser: this.parser
|
||||||
|
|
||||||
|
require.registerExtension '.coffee', (content) ->
|
||||||
|
require('coffee-script').compile content
|
||||||
|
|
||||||
# The current CoffeeScript version number.
|
# The current CoffeeScript version number.
|
||||||
exports.VERSION: '0.5.5'
|
exports.VERSION: '0.5.5'
|
||||||
|
|
||||||
|
|||||||
2
test/test_importing.coffee
Normal file
2
test/test_importing.coffee
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
# Check if it can import a coffeescript-only module and check its output
|
||||||
|
ok (require 'test_module').foo is "bar"
|
||||||
1
test/test_module.coffee
Normal file
1
test/test_module.coffee
Normal file
@@ -0,0 +1 @@
|
|||||||
|
exports.foo: "bar"
|
||||||
Reference in New Issue
Block a user