mirror of
https://github.com/jashkenas/coffeescript.git
synced 2022-11-09 12:23:24 -05:00
Merge pull request #3279 from michaelficarra/fix-require.extensions-registration
fix require.extensions registration
This commit is contained in:
commit
8cd9ba168d
10 changed files with 18 additions and 6 deletions
2
Cakefile
2
Cakefile
|
@ -161,7 +161,7 @@ task 'bench', 'quick benchmark of compilation time', ->
|
|||
|
||||
# Run the CoffeeScript test suite.
|
||||
runTests = (CoffeeScript) ->
|
||||
require './lib/coffee-script/extensions'
|
||||
CoffeeScript.register()
|
||||
startTime = Date.now()
|
||||
currentFile = null
|
||||
passedTests = 0
|
||||
|
|
|
@ -182,6 +182,10 @@
|
|||
}
|
||||
};
|
||||
|
||||
exports.register = function() {
|
||||
return require('./register');
|
||||
};
|
||||
|
||||
exports._compileFile = function(filename, sourceMap) {
|
||||
var answer, err, raw, stripped;
|
||||
if (sourceMap == null) {
|
||||
|
|
|
@ -178,6 +178,7 @@
|
|||
} else if (o.nodes) {
|
||||
return printLine(CoffeeScript.nodes(t.input, t.options).toString().trim());
|
||||
} else if (o.run) {
|
||||
CoffeeScript.register();
|
||||
return CoffeeScript.run(t.input, t.options);
|
||||
} else if (o.join && t.file !== o.join) {
|
||||
if (helpers.isLiterate(file)) {
|
||||
|
|
|
@ -145,7 +145,7 @@
|
|||
console.warn("Node 0.8.0+ required for CoffeeScript REPL");
|
||||
process.exit(1);
|
||||
}
|
||||
require('./extensions');
|
||||
CoffeeScript.register();
|
||||
process.argv = ['coffee'].concat(process.argv.slice(2));
|
||||
opts = merge(replDefaults, opts);
|
||||
repl = nodeREPL.start(opts);
|
||||
|
|
1
register.js
Normal file
1
register.js
Normal file
|
@ -0,0 +1 @@
|
|||
require('./lib/coffee-script/register');
|
|
@ -156,6 +156,8 @@ exports.eval = (code, options = {}) ->
|
|||
else
|
||||
vm.runInContext js, sandbox
|
||||
|
||||
exports.register = -> require './register'
|
||||
|
||||
exports._compileFile = (filename, sourceMap = no) ->
|
||||
raw = fs.readFileSync filename, 'utf8'
|
||||
stripped = if raw.charCodeAt(0) is 0xFEFF then raw.substring 1 else raw
|
||||
|
|
|
@ -133,9 +133,13 @@ compileScript = (file, input, base = null) ->
|
|||
try
|
||||
t = task = {file, input, options}
|
||||
CoffeeScript.emit 'compile', task
|
||||
if o.tokens then printTokens CoffeeScript.tokens t.input, t.options
|
||||
else if o.nodes then printLine CoffeeScript.nodes(t.input, t.options).toString().trim()
|
||||
else if o.run then CoffeeScript.run t.input, t.options
|
||||
if o.tokens
|
||||
printTokens CoffeeScript.tokens t.input, t.options
|
||||
else if o.nodes
|
||||
printLine CoffeeScript.nodes(t.input, t.options).toString().trim()
|
||||
else if o.run
|
||||
CoffeeScript.register()
|
||||
CoffeeScript.run t.input, t.options
|
||||
else if o.join and t.file isnt o.join
|
||||
t.input = helpers.invertLiterate t.input if helpers.isLiterate file
|
||||
sourceCode[sources.indexOf(t.file)] = t.input
|
||||
|
|
|
@ -131,7 +131,7 @@ module.exports =
|
|||
console.warn "Node 0.8.0+ required for CoffeeScript REPL"
|
||||
process.exit 1
|
||||
|
||||
require './extensions'
|
||||
CoffeeScript.register()
|
||||
process.argv = ['coffee'].concat process.argv[2..]
|
||||
opts = merge replDefaults, opts
|
||||
repl = nodeREPL.start opts
|
||||
|
|
Loading…
Reference in a new issue