Commit 8c5f4cb5 8c5f4cb5ada854c3e1fd374842413106f24b6035 by Nicolas Perriault

sourceIds object is now attached to phantomjs object

1 parent 9fa750e8
Showing 1 changed file with 6 additions and 6 deletions
...@@ -27,8 +27,6 @@ ...@@ -27,8 +27,6 @@
27 * DEALINGS IN THE SOFTWARE. 27 * DEALINGS IN THE SOFTWARE.
28 * 28 *
29 */ 29 */
30 var sourceIds = {};
31
32 if (!phantom.casperLoaded) { 30 if (!phantom.casperLoaded) {
33 // see http://semver.org/ 31 // see http://semver.org/
34 phantom.casperVersion = { 32 phantom.casperVersion = {
...@@ -73,8 +71,10 @@ if (!phantom.casperLoaded) { ...@@ -73,8 +71,10 @@ if (!phantom.casperLoaded) {
73 phantom.injectJs(fs.pathJoin(phantom.casperPath, 'modules', 'vendors', 'coffee-script.js')); 71 phantom.injectJs(fs.pathJoin(phantom.casperPath, 'modules', 'vendors', 'coffee-script.js'));
74 72
75 // Adding built-in capabilities to phantom object 73 // Adding built-in capabilities to phantom object
74 phantom.sourceIds = {};
75
76 phantom.getErrorMessage = function(e) { 76 phantom.getErrorMessage = function(e) {
77 return (e.fileName || sourceIds[e.sourceId]) + ':' + e.line + ' ' + e; 77 return (e.fileName || phantom.sourceIds[e.sourceId]) + ':' + e.line + ' ' + e;
78 }; 78 };
79 79
80 phantom.getScriptCode = function(file, onError) { 80 phantom.getScriptCode = function(file, onError) {
...@@ -94,14 +94,14 @@ if (!phantom.casperLoaded) { ...@@ -94,14 +94,14 @@ if (!phantom.casperLoaded) {
94 }; 94 };
95 95
96 phantom.processScriptError = function(error, file, callback) { 96 phantom.processScriptError = function(error, file, callback) {
97 if (!sourceIds.hasOwnProperty(error.sourceId)) { 97 if (!phantom.sourceIds.hasOwnProperty(error.sourceId)) {
98 sourceIds[error.sourceId] = file; 98 phantom.sourceIds[error.sourceId] = file;
99 } 99 }
100 if (error.message === "__sourceId__") { 100 if (error.message === "__sourceId__") {
101 return; 101 return;
102 } 102 }
103 if (typeof callback === "function") { 103 if (typeof callback === "function") {
104 callback(error); 104 callback(error, file);
105 } else { 105 } else {
106 console.error(phantom.getErrorMessage(error)); 106 console.error(phantom.getErrorMessage(error));
107 phantom.exit(1); 107 phantom.exit(1);
......