Commit 4019e76d 4019e76dbc07a508a862ac3f84688667574e8c4e by Nicolas Perriault

added the python-like __file__ variable available within modules

1 parent 34f47682
...@@ -205,9 +205,9 @@ phantom.loadCasper = function loadCasper() { ...@@ -205,9 +205,9 @@ phantom.loadCasper = function loadCasper() {
205 return requireCache[file].exports; 205 return requireCache[file].exports;
206 } 206 }
207 var scriptCode = phantom.getScriptCode(file); 207 var scriptCode = phantom.getScriptCode(file);
208 var fn = new Function('require', 'module', 'exports', scriptCode); 208 var fn = new Function('__file__', 'require', 'module', 'exports', scriptCode);
209 try { 209 try {
210 fn(_require, module, module.exports); 210 fn(file, _require, module, module.exports);
211 } catch (e) { 211 } catch (e) {
212 var error = new CasperError('__mod_error(' + path + '):: ' + e); 212 var error = new CasperError('__mod_error(' + path + '):: ' + e);
213 error.file = file; 213 error.file = file;
......