Using process.mainModule.filename instead of passing __filename

This commit is contained in:
Trevor Burnham 2011-04-30 23:01:36 -04:00
parent 264070bfc7
commit fc992ba380
3 changed files with 5 additions and 5 deletions

View File

@ -4,4 +4,4 @@ var path = require('path');
var fs = require('fs'); var fs = require('fs');
var lib = path.join(path.dirname(fs.realpathSync(__filename)), '../lib'); var lib = path.join(path.dirname(fs.realpathSync(__filename)), '../lib');
require(lib + '/command').run(__filename); require(lib + '/command').run();

View File

@ -20,7 +20,7 @@
sources = []; sources = [];
contents = []; contents = [];
optionParser = null; optionParser = null;
exports.run = function(coffeePath) { exports.run = function() {
parseOptions(); parseOptions();
if (opts.nodejs) { if (opts.nodejs) {
return forkNode(); return forkNode();
@ -51,7 +51,7 @@
} }
process.ARGV = process.argv = process.argv.slice(0, 2).concat(opts.literals); process.ARGV = process.argv = process.argv.slice(0, 2).concat(opts.literals);
process.argv[0] = 'coffee'; process.argv[0] = 'coffee';
process.execPath = coffeePath; process.execPath = process.mainModule.filename;
return compileScripts(); return compileScripts();
}; };
compileScripts = function() { compileScripts = function() {

View File

@ -53,7 +53,7 @@ optionParser = null
# Run `coffee` by parsing passed options and determining what action to take. # Run `coffee` by parsing passed options and determining what action to take.
# Many flags cause us to divert before compiling anything. Flags passed after # Many flags cause us to divert before compiling anything. Flags passed after
# `--` will be passed verbatim to your script as arguments in `process.argv` # `--` will be passed verbatim to your script as arguments in `process.argv`
exports.run = (coffeePath) -> exports.run = ->
parseOptions() parseOptions()
return forkNode() if opts.nodejs return forkNode() if opts.nodejs
return usage() if opts.help return usage() if opts.help
@ -67,7 +67,7 @@ exports.run = (coffeePath) ->
opts.literals = sources.splice(1).concat opts.literals opts.literals = sources.splice(1).concat opts.literals
process.ARGV = process.argv = process.argv.slice(0, 2).concat opts.literals process.ARGV = process.argv = process.argv.slice(0, 2).concat opts.literals
process.argv[0] = 'coffee' process.argv[0] = 'coffee'
process.execPath = coffeePath process.execPath = process.mainModule.filename
compileScripts() compileScripts()
# Asynchronously read in each CoffeeScript in a list of source files and # Asynchronously read in each CoffeeScript in a list of source files and