Expanding __filename and __dirname when running with the coffee command -- Issue #771

This commit is contained in:
Jeremy Ashkenas
2010-10-24 14:19:47 -04:00
parent 6347849cd0
commit 08527075b7
2 changed files with 6 additions and 6 deletions

View File

@@ -1,10 +1,10 @@
(function() {
var Lexer, compile, fs, lexer, parser, path;
fs = require('fs');
path = require('path');
Lexer = require('./lexer').Lexer;
parser = require('./parser').parser;
if (require.extensions) {
fs = require('fs');
require.extensions['.coffee'] = function(module, filename) {
var content;
content = compile(fs.readFileSync(filename, 'utf8'));
@@ -40,7 +40,7 @@
while (root.parent) {
root = root.parent;
}
root.filename = options.fileName;
root.filename = fs.realpathSync(options.fileName);
if (root.moduleCache) {
root.moduleCache = {};
}
@@ -48,7 +48,7 @@
};
exports.eval = function(code, options) {
var __dirname, __filename;
__filename = options.fileName;
__filename = fs.realpathSync(options.fileName);
__dirname = path.dirname(__filename);
return eval(exports.compile(code, options));
};