diff --git a/Cakefile b/Cakefile index 8ccbe7bc..77c7c4db 100644 --- a/Cakefile +++ b/Cakefile @@ -111,10 +111,10 @@ task 'test', 'run the CoffeeScript language test suite', -> fs.readdir 'test', (err, files) -> files.forEach (file) -> return unless file.match(/\.coffee$/i) - source = path.join 'test', file - fs.readFile source, (err, code) -> + fileName = path.join 'test', file + fs.readFile fileName, (err, code) -> try - CoffeeScript.run code.toString(), {source: source} + CoffeeScript.run code.toString(), {fileName} catch err failedTests += 1 - log "failed #source", red, '\n' + err.stack.toString() + log "failed #fileName", red, '\n' + err.stack.toString() diff --git a/lib/cake.js b/lib/cake.js index 2dbc93e0..0ca9f6f8 100755 --- a/lib/cake.js +++ b/lib/cake.js @@ -41,7 +41,7 @@ } args = process.argv.slice(2, process.argv.length); CoffeeScript.run(fs.readFileSync('Cakefile').toString(), { - source: 'Cakefile' + fileName: 'Cakefile' }); oparse = new optparse.OptionParser(switches); if (!(args.length)) { diff --git a/lib/coffee-script.js b/lib/coffee-script.js index a476bb0f..6a0441a3 100644 --- a/lib/coffee-script.js +++ b/lib/coffee-script.js @@ -22,8 +22,8 @@ try { return (parser.parse(lexer.tokenize(code))).compile(options); } catch (err) { - if (options.source) { - err.message = ("In " + options.source + ", " + err.message); + if (options.fileName) { + err.message = ("In " + options.fileName + ", " + err.message); } throw err; } @@ -36,7 +36,7 @@ }; exports.run = (function(code, options) { var __dirname, __filename; - module.filename = (__filename = options.source); + module.filename = (__filename = options.fileName); __dirname = path.dirname(__filename); return eval(exports.compile(code, options)); }); diff --git a/lib/command.js b/lib/command.js index f99355fd..b580bd18 100644 --- a/lib/command.js +++ b/lib/command.js @@ -197,10 +197,10 @@ options.print = !!(o.print || (o.eval || o.stdio && o.compile)); return (sources = options.arguments); }; - compileOptions = function(source) { + compileOptions = function(fileName) { var o; o = { - source: source + fileName: fileName }; o.noWrap = options['no-wrap']; return o; diff --git a/lib/repl.js b/lib/repl.js index ca5584fe..bb62ff45 100644 --- a/lib/repl.js +++ b/lib/repl.js @@ -15,7 +15,7 @@ val = CoffeeScript.run(buffer.toString(), { noWrap: true, globals: true, - source: 'repl' + fileName: 'repl' }); if (val !== undefined) { puts(inspect(val)); diff --git a/src/cake.coffee b/src/cake.coffee index 018aa1c2..a36512d7 100644 --- a/src/cake.coffee +++ b/src/cake.coffee @@ -47,7 +47,7 @@ exports.run = -> path.exists 'Cakefile', (exists) -> throw new Error("Cakefile not found in #{process.cwd()}") unless exists args = process.argv[2...process.argv.length] - CoffeeScript.run fs.readFileSync('Cakefile').toString(), source: 'Cakefile' + CoffeeScript.run fs.readFileSync('Cakefile').toString(), fileName: 'Cakefile' oparse = new optparse.OptionParser switches return printTasks() unless args.length options = oparse.parse(args) diff --git a/src/coffee-script.coffee b/src/coffee-script.coffee index 2d32c01e..32b9ff19 100644 --- a/src/coffee-script.coffee +++ b/src/coffee-script.coffee @@ -34,7 +34,7 @@ exports.compile = compile = (code, options) -> try (parser.parse lexer.tokenize code).compile options catch err - err.message = "In #options.source, #err.message" if options.source + err.message = "In #options.fileName, #err.message" if options.fileName throw err # Tokenize a string of CoffeeScript code, and return the array of tokens. @@ -50,7 +50,7 @@ exports.nodes = (code) -> # Compile and execute a string of CoffeeScript (on the server), correctly # setting `__filename`, `__dirname`, and relative `require()`. exports.run = ((code, options) -> - module.filename = __filename = options.source + module.filename = __filename = options.fileName __dirname = path.dirname __filename eval exports.compile code, options ) diff --git a/src/command.coffee b/src/command.coffee index c4e7217a..895def7c 100644 --- a/src/command.coffee +++ b/src/command.coffee @@ -162,8 +162,8 @@ parseOptions = -> sources = options.arguments # The compile-time options to pass to the CoffeeScript compiler. -compileOptions = (source) -> - o = {source} +compileOptions = (fileName) -> + o = {fileName} o.noWrap = options['no-wrap'] o diff --git a/src/repl.coffee b/src/repl.coffee index 2added2b..233e1f3e 100644 --- a/src/repl.coffee +++ b/src/repl.coffee @@ -20,7 +20,7 @@ helpers.extend global, quit: -> process.exit(0) # of exiting. run = (buffer) -> try - val = CoffeeScript.run buffer.toString(), noWrap: true, globals: true, source: 'repl' + val = CoffeeScript.run buffer.toString(), noWrap: true, globals: true, fileName: 'repl' puts inspect val if val isnt undefined catch err puts err.stack or err.toString() diff --git a/test/test_compilation.coffee b/test/test_compilation.coffee index 41c68098..9f664640 100644 --- a/test/test_compilation.coffee +++ b/test/test_compilation.coffee @@ -8,7 +8,7 @@ ok js is "one;\ntwo;" global.resultArray = [] -CoffeeScript.run("resultArray.push i for i of global", {noWrap: on, globals: on, source: 'tests'}) +CoffeeScript.run("resultArray.push i for i of global", {noWrap: on, globals: on, fileName: 'tests'}) ok 'setInterval' in global.resultArray