added the python-like __file__ variable available within modules
Showing
1 changed file
with
2 additions
and
2 deletions
... | @@ -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; | ... | ... |
-
Please register or sign in to post a comment