CoffeeScript.run should be able to safely omit options

This commit is contained in:
Michael Ficarra
2012-01-12 19:25:51 -05:00
parent 6d33a2e1a0
commit 0c5726d3ab
2 changed files with 2 additions and 1 deletions

View File

@@ -64,6 +64,7 @@
exports.run = function(code, options) {
var mainModule;
if (options == null) options = {};
mainModule = require.main;
mainModule.filename = process.argv[1] = options.filename ? fs.realpathSync(options.filename) : '.';
mainModule.moduleCache && (mainModule.moduleCache = {});

View File

@@ -57,7 +57,7 @@ exports.nodes = (source, options) ->
# Compile and execute a string of CoffeeScript (on the server), correctly
# setting `__filename`, `__dirname`, and relative `require()`.
exports.run = (code, options) ->
exports.run = (code, options = {}) ->
mainModule = require.main
# Set the filename.