Skip to content

Commit

Permalink
fix __filename and __dirname on server
Browse files Browse the repository at this point in the history
  • Loading branch information
guybedford committed Dec 18, 2014
1 parent 95a9c6b commit 53338cc
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/extension-cjs.js
Expand Up @@ -47,12 +47,16 @@ function cjs(loader) {
dirname.pop();
dirname = dirname.join('/');

// if on the server, remove the "file:" part from the dirname
if (System._nodeRequire)
dirname = dirname.substr(5);

var globals = loader.global._g = {
global: loader.global,
exports: exports,
module: module,
require: require,
__filename: load.address,
__filename: System._nodeRequire ? load.address.substr(5) : load.address,
__dirname: dirname
};

Expand Down

0 comments on commit 53338cc

Please sign in to comment.