From fc992ba380144e33b3af39d3f67ad66e5b582e7e Mon Sep 17 00:00:00 2001 From: Trevor Burnham Date: Sat, 30 Apr 2011 23:01:36 -0400 Subject: [PATCH] Using process.mainModule.filename instead of passing __filename --- bin/coffee | 2 +- lib/command.js | 4 ++-- src/command.coffee | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/bin/coffee b/bin/coffee index 67e803d0..4dc0a5ec 100755 --- a/bin/coffee +++ b/bin/coffee @@ -4,4 +4,4 @@ var path = require('path'); var fs = require('fs'); var lib = path.join(path.dirname(fs.realpathSync(__filename)), '../lib'); -require(lib + '/command').run(__filename); +require(lib + '/command').run(); diff --git a/lib/command.js b/lib/command.js index fa423ef9..17c3782d 100644 --- a/lib/command.js +++ b/lib/command.js @@ -20,7 +20,7 @@ sources = []; contents = []; optionParser = null; - exports.run = function(coffeePath) { + exports.run = function() { parseOptions(); if (opts.nodejs) { return forkNode(); @@ -51,7 +51,7 @@ } process.ARGV = process.argv = process.argv.slice(0, 2).concat(opts.literals); process.argv[0] = 'coffee'; - process.execPath = coffeePath; + process.execPath = process.mainModule.filename; return compileScripts(); }; compileScripts = function() { diff --git a/src/command.coffee b/src/command.coffee index d6c70aa2..3e574fe5 100644 --- a/src/command.coffee +++ b/src/command.coffee @@ -53,7 +53,7 @@ optionParser = null # Run `coffee` by parsing passed options and determining what action to take. # Many flags cause us to divert before compiling anything. Flags passed after # `--` will be passed verbatim to your script as arguments in `process.argv` -exports.run = (coffeePath) -> +exports.run = -> parseOptions() return forkNode() if opts.nodejs return usage() if opts.help @@ -67,7 +67,7 @@ exports.run = (coffeePath) -> opts.literals = sources.splice(1).concat opts.literals process.ARGV = process.argv = process.argv.slice(0, 2).concat opts.literals process.argv[0] = 'coffee' - process.execPath = coffeePath + process.execPath = process.mainModule.filename compileScripts() # Asynchronously read in each CoffeeScript in a list of source files and