Using process.mainModule.filename instead of passing __filename
This commit is contained in:
parent
264070bfc7
commit
fc992ba380
|
@ -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();
|
||||||
|
|
|
@ -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() {
|
||||||
|
|
|
@ -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
|
||||||
|
|
Loading…
Reference in New Issue