Since the REPL compilation path is unique (in eval
above), we need
another way to get the options
object attached to a module so that
it knows later on whether it needs to be transpiled. In the case of
the REPL, the only applicable option is transpile
.
Module = require 'module'
originalModuleLoad = Module::load
Module::load = (filename) ->
@options = transpile: transpile.options
originalModuleLoad.call @, filename
opts = merge replDefaults, opts
repl = nodeREPL.start opts
runInContext opts.prelude, repl.context, 'prelude' if opts.prelude
repl.on 'exit', -> repl.outputStream.write '\n' if not repl.closed
addMultilineHandler repl
addHistory repl, opts.historyFile, opts.historyMaxInputSize if opts.historyFile