[Pkg-javascript-commits] [less.js] 155/285: move browser log code out to log listener and remove option I added temporarily that wasn't an opiption

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 91025dbe7e2f184a869fa4e55fd1b1f15c535fe9
Author: Luke Page <luke.a.page at gmail.com>
Date:   Tue Oct 7 21:05:26 2014 +0100

    move browser log code out to log listener and remove option I added temporarily that wasn't an opiption
---
 lib/less-browser/index.js        | 49 +---------------------------------------
 lib/less-browser/log-listener.js | 43 +++++++++++++++++++++++++++++++++++
 lib/less/contexts.js             |  3 +--
 3 files changed, 45 insertions(+), 50 deletions(-)

diff --git a/lib/less-browser/index.js b/lib/less-browser/index.js
index 86e5ec9..4ddb66b 100644
--- a/lib/less-browser/index.js
+++ b/lib/less-browser/index.js
@@ -7,9 +7,6 @@ var less;
 
 /*
   TODO - options is now hidden - we should expose it on the less object, but not have it "as" the less object
-         alternately even have it on environment
-         e.g. less.environment.options.fileAsync = true;
-         is it weird you do
          less = { fileAsync: true }
          then access as less.environment.options.fileAsync ?
  */
@@ -22,39 +19,7 @@ var environment = less.environment,
     browserImport = require("./browser-import")(options, isFileProtocol, less.logger);
 environment.addFileManager(browserImport);
 
-var logLevel = {
-    debug: 3,
-    info: 2,
-    errors: 1,
-    none: 0
-};
-if (!options.loggers) {
-    options.loggers = [{
-        debug: function(msg) {
-            if (options.logLevel >= logLevel.debug) {
-                console.log(msg);
-            }
-        },
-        info: function(msg) {
-            if (options.logLevel >= logLevel.info) {
-                console.log(msg);
-            }
-        },
-        warn: function(msg) {
-            if (options.logLevel >= logLevel.warn) {
-                console.warn(msg);
-            }
-        },
-        error: function(msg) {
-            if (options.logLevel >= logLevel.error) {
-                console.error(msg);
-            }
-        }
-    }];
-}
-for(var i = 0; i < options.loggers.length; i++) {
-    less.logger.addListener(options.loggers[i]);
-}
+require("./log-listener")(less, options);
 
 less.env = options.env || (location.hostname == '127.0.0.1' ||
                         location.hostname == '0.0.0.0'   ||
@@ -64,18 +29,6 @@ less.env = options.env || (location.hostname == '127.0.0.1' ||
                         isFileProtocol                   ? 'development'
                                                          : 'production');
 
-if (!options.hasOwnProperty('disableDataURIs')) {
-    options.disableDataURIs = true;
-}
-
-// The amount of logging in the javascript console.
-// 3 - Debug, information and errors
-// 2 - Information and errors
-// 1 - Errors
-// 0 - None
-// Defaults to 2
-less.logLevel = typeof(options.logLevel) != 'undefined' ? options.logLevel : (less.env === 'development' ?  logLevel.debug : logLevel.errors);
-
 // Load styles asynchronously (default: false)
 //
 // This is set to `false` by default, so that the body
diff --git a/lib/less-browser/log-listener.js b/lib/less-browser/log-listener.js
new file mode 100644
index 0000000..1b1ad59
--- /dev/null
+++ b/lib/less-browser/log-listener.js
@@ -0,0 +1,43 @@
+module.exports = function(less, options) {
+
+    var logLevel_debug = 3,
+        logLevel_info = 2,
+        logLevel_errors = 1,
+        logLevel_none =  0;
+
+    // The amount of logging in the javascript console.
+    // 3 - Debug, information and errors
+    // 2 - Information and errors
+    //  1 - Errors
+    // 0 - None
+    // Defaults to 2
+    options.logLevel = typeof(options.logLevel) !== 'undefined' ? options.logLevel : (options.env === 'development' ?  logLevel_debug : logLevel_errors);
+
+    if (!options.loggers) {
+        options.loggers = [{
+            debug: function(msg) {
+                if (options.logLevel >= logLevel_debug) {
+                    console.log(msg);
+                }
+            },
+            info: function(msg) {
+                if (options.logLevel >= logLevel_info) {
+                    console.log(msg);
+                }
+            },
+            warn: function(msg) {
+                if (options.logLevel >= logLevel_warn) {
+                    console.warn(msg);
+                }
+            },
+            error: function(msg) {
+                if (options.logLevel >= logLevel_error) {
+                    console.error(msg);
+                }
+            }
+        }];
+    }
+    for(var i = 0; i < options.loggers.length; i++) {
+        less.logger.addListener(options.loggers[i]);
+    }
+};
diff --git a/lib/less/contexts.js b/lib/less/contexts.js
index ca34051..96335a7 100644
--- a/lib/less/contexts.js
+++ b/lib/less/contexts.js
@@ -47,8 +47,7 @@ var evalCopyProperties = [
     'sourceMap',      // whether to output a source map
     'importMultiple', // whether we are currently importing multiple copies
     'urlArgs',        // whether to add args into url tokens
-    'javascriptEnabled',// option - whether JavaScript is enabled. if undefined, defaults to true
-    'disableDataURIs' // option - disable data URIs (they will be converted to URL())
+    'javascriptEnabled'// option - whether JavaScript is enabled. if undefined, defaults to true
     ];
 
 contexts.Eval = function(options, frames) {

-- 
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