Commit 22f5e13f 22f5e13f4b49973735b57ceb5a0c0c3b65dd2137 by Nicolas Perriault

ensure patched require() is available within scripts

1 parent a24309d3
...@@ -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 }
......