[Pkg-javascript-commits] [less.js] 149/285: Fix final weird error - in phantom only some console.log calls are going missing?

Jonas Smedegaard dr at jones.dk
Mon Oct 26 23:23:49 UTC 2015


This is an automated email from the git hooks/post-receive script.

js pushed a commit to annotated tag v2.0.0
in repository less.js.

commit 3af09233b1b64fad6d45e9ca255e54476f3cadac
Author: Luke Page <luke.a.page at gmail.com>
Date:   Sun Oct 5 10:42:38 2014 +0100

    Fix final weird error - in phantom only some console.log calls are going missing?
---
 lib/less-browser/index.js           |  4 +++-
 lib/less/environment/environment.js |  8 +++++---
 test/browser/common.js              | 19 ++++++++++++++-----
 3 files changed, 22 insertions(+), 9 deletions(-)

diff --git a/lib/less-browser/index.js b/lib/less-browser/index.js
index 375f94f..54e038c 100644
--- a/lib/less-browser/index.js
+++ b/lib/less-browser/index.js
@@ -14,7 +14,9 @@ var less;
 
 function log(str, level) {
     if (typeof(console) !== 'undefined' && less.logLevel >= level) {
-        console.log('less: ' + str);
+        //TODO no idea why console.log has stopped working in phantom
+        //move to a proper logger and registering a listener
+        console.warn('less: ' + str);
     }
 }
 
diff --git a/lib/less/environment/environment.js b/lib/less/environment/environment.js
index aeb8805..84b4160 100644
--- a/lib/less/environment/environment.js
+++ b/lib/less/environment/environment.js
@@ -1,14 +1,16 @@
 var environment = function(externalEnvironment, fileManagers) {
     this.fileManagers = fileManagers || [];
-    var functions = ["warn", "encodeBase64", "mimeLookup", "charsetLookup", "getSourceMapGenerator"];
+    var optionalFunctions = ["encodeBase64", "mimeLookup", "charsetLookup", "getSourceMapGenerator"],
+        requiredFunctions = ["warn"],
+        functions = requiredFunctions.concat(optionalFunctions);
 
     for(var i = 0; i < functions.length; i++) {
         var propName = functions[i],
             environmentFunc = externalEnvironment[propName];
         if (environmentFunc) {
             this[propName] = environmentFunc.bind(externalEnvironment);
-        } else {
-            this.warn("missing function in environment - " + propName);
+        } else if (i < requiredFunctions.length) {
+            this.warn("missing required function in environment - " + propName);
         }
     }
 };
diff --git a/test/browser/common.js b/test/browser/common.js
index 21ec8a3..09e2e54 100644
--- a/test/browser/common.js
+++ b/test/browser/common.js
@@ -10,11 +10,20 @@
 //   }
 // };
 
-var logMessages = [],
-  realConsoleLog = console.log;
-console.log = function(msg) {
-  logMessages.push(msg);
-  realConsoleLog.call(console, msg);
+var oldconsole = window.console;
+var logMessages = [];
+window.console = {
+    warn: function(msg) {
+        oldconsole.warn(msg);
+        logMessages.push(msg);
+    },
+    log: function(msg) {
+        oldconsole.log(msg);
+        logMessages.push(msg);
+    },
+    error: function(msg) {
+        oldconsole.error(msg);
+    }
 };
 
 var testLessEqualsInDocument = function() {

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/less.js.git



More information about the Pkg-javascript-commits mailing list