ensure patched require() is available within scripts
Showing
1 changed file
with
2 additions
and
2 deletions
... | @@ -192,7 +192,6 @@ phantom.loadCasper = function loadCasper() { | ... | @@ -192,7 +192,6 @@ phantom.loadCasper = function loadCasper() { |
192 | * @param Function callback An optional callback | 192 | * @param Function callback An optional callback |
193 | */ | 193 | */ |
194 | phantom.processScriptError = function processScriptError(error, file, callback) { | 194 | phantom.processScriptError = function processScriptError(error, file, callback) { |
195 | console.log(error, file, callback) | ||
196 | if (error.sourceId && !this.sourceIds.hasOwnProperty(error.sourceId)) { | 195 | if (error.sourceId && !this.sourceIds.hasOwnProperty(error.sourceId)) { |
197 | this.sourceIds[error.sourceId] = file; | 196 | this.sourceIds[error.sourceId] = file; |
198 | } | 197 | } |
... | @@ -269,7 +268,8 @@ phantom.loadCasper = function loadCasper() { | ... | @@ -269,7 +268,8 @@ phantom.loadCasper = function loadCasper() { |
269 | } | 268 | } |
270 | try { | 269 | try { |
271 | var scriptCode = phantom.getScriptCode(file); | 270 | var scriptCode = phantom.getScriptCode(file); |
272 | new Function('module', 'exports', scriptCode)(module, module.exports); | 271 | var fn = new Function('require', 'module', 'exports', scriptCode); |
272 | fn(_require, module, module.exports); | ||
273 | } catch (e) { | 273 | } catch (e) { |
274 | phantom.processScriptError(e, file); | 274 | phantom.processScriptError(e, file); |
275 | } | 275 | } | ... | ... |
-
Please register or sign in to post a comment