Skip to content

Commit

Permalink
Merge pull request #3279 from michaelficarra/fix-require.extensions-r…
Browse files Browse the repository at this point in the history
…egistration

fix require.extensions registration
  • Loading branch information
jashkenas committed Dec 8, 2013
2 parents 94e22ab + 08a5789 commit 8cd9ba1
Show file tree
Hide file tree
Showing 10 changed files with 18 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Cakefile
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions lib/coffee-script/coffee-script.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions lib/coffee-script/command.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

File renamed without changes.
2 changes: 1 addition & 1 deletion lib/coffee-script/repl.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions register.js
@@ -0,0 +1 @@
require('./lib/coffee-script/register');
2 changes: 2 additions & 0 deletions src/coffee-script.coffee
Expand Up @@ -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
Expand Down
10 changes: 7 additions & 3 deletions src/command.coffee
Expand Up @@ -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
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion src/repl.coffee
Expand Up @@ -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
Expand Down

0 comments on commit 8cd9ba1

Please sign in to comment.