Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

fix auto and manual require.extensions registration; ref #3141

You can now `require('coffee-script/register')` to manually register,
and the compiler auto-registers when directly running a coffee file.
  • Loading branch information...
commit ba4743cc834784a1af70f98564960158dfbf9e82 1 parent 94e22ab
@michaelficarra michaelficarra authored
View
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'
+ require './lib/coffee-script/register'
startTime = Date.now()
currentFile = null
passedTests = 0
View
1  lib/coffee-script/command.js
@@ -178,6 +178,7 @@
} else if (o.nodes) {
return printLine(CoffeeScript.nodes(t.input, t.options).toString().trim());
} else if (o.run) {
+ require('./register');
return CoffeeScript.run(t.input, t.options);
} else if (o.join && t.file !== o.join) {
if (helpers.isLiterate(file)) {
View
0  lib/coffee-script/extensions.js → lib/coffee-script/register.js
File renamed without changes
View
2  lib/coffee-script/repl.js
@@ -145,7 +145,7 @@
console.warn("Node 0.8.0+ required for CoffeeScript REPL");
process.exit(1);
}
- require('./extensions');
+ require('./register');
process.argv = ['coffee'].concat(process.argv.slice(2));
opts = merge(replDefaults, opts);
repl = nodeREPL.start(opts);
View
1  register.js
@@ -0,0 +1 @@
+require('./lib/coffee-script/register');
View
10 src/command.coffee
@@ -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
+ require './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
View
0  src/extensions.coffee → src/register.coffee
File renamed without changes
View
2  src/repl.coffee
@@ -131,7 +131,7 @@ module.exports =
console.warn "Node 0.8.0+ required for CoffeeScript REPL"
process.exit 1
- require './extensions'
+ require './register'
process.argv = ['coffee'].concat process.argv[2..]
opts = merge replDefaults, opts
repl = nodeREPL.start opts
Please sign in to comment.
Something went wrong with that request. Please try again.