[Pkg-javascript-commits] [less.js] 94/285: seperate out the environments at the top-most-level

Jonas Smedegaard dr at jones.dk
Mon Oct 26 23:23:42 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 d9c42e206d7c26e8c35a6b270678303ac83cdd78
Author: Luke Page <luke.a.page at gmail.com>
Date:   Thu Sep 4 19:11:59 2014 +0100

    seperate out the environments at the top-most-level
---
 Gruntfile.js                                       |  2 +-
 bin/lessc                                          |  6 +-
 .../browser.js => less-browser/environment.js}     |  0
 lib/{less/browser.js => less-browser/index.js}     |  4 +-
 .../node.js => less-node/environment.js}           |  2 +-
 lib/{less/environment/node => less-node}/fs.js     |  0
 lib/{less => less-node}/index.js                   |  6 +-
 .../lessc_helper.js => less-node/lessc-helper.js}  |  0
 lib/less/environment/api.js                        |  6 +-
 lib/less/index.js                                  | 73 +++++-----------------
 lib/less/non-node-index.js                         | 15 -----
 test/index.js                                      |  2 +-
 test/less-test.js                                  |  4 +-
 13 files changed, 30 insertions(+), 90 deletions(-)

diff --git a/Gruntfile.js b/Gruntfile.js
index 9a70c8d..126cb23 100644
--- a/Gruntfile.js
+++ b/Gruntfile.js
@@ -49,7 +49,7 @@ module.exports = function (grunt) {
 
         browserify: {
             browser: {
-                src: ['./lib/less/browser.js'],
+                src: ['./lib/less-browser/index.js'],
                 dest: 'tmp/less.js'
             }
         },
diff --git a/bin/lessc b/bin/lessc
index 9edcd95..d8e1953 100755
--- a/bin/lessc
+++ b/bin/lessc
@@ -1,11 +1,11 @@
 #!/usr/bin/env node
 
 var path = require('path'),
-    fs = require('../lib/less/environment/node/fs'),
+    fs = require('../lib/less-node/fs'),
     os = require('os'),
     mkdirp;
 
-var less = require('../lib/less');
+var less = require('../lib/less-node');
 var args = process.argv.slice(1);
 var options = {
     depends: false,
@@ -98,7 +98,7 @@ args = args.filter(function (arg) {
             break;
         case 'h':
         case 'help':
-            require('../lib/less/lessc_helper').printUsage();
+            require('../lib/less-node/lessc-helper').printUsage();
             continueProcessing = false;
             break;
         case 'x':
diff --git a/lib/less/environment/browser.js b/lib/less-browser/environment.js
similarity index 100%
rename from lib/less/environment/browser.js
rename to lib/less-browser/environment.js
diff --git a/lib/less/browser.js b/lib/less-browser/index.js
similarity index 99%
rename from lib/less/browser.js
rename to lib/less-browser/index.js
index 5b9e9e0..7b71548 100644
--- a/lib/less/browser.js
+++ b/lib/less-browser/index.js
@@ -29,9 +29,9 @@ function log(str, level) {
 
 var isFileProtocol = /^(file|chrome(-extension)?|resource|qrc|app):/.test(location.protocol),
     options = window.less,
-    environment = require("./environment/browser.js")(options, isFileProtocol, log, logLevel);
+    environment = require("./environment.js")(options, isFileProtocol, log, logLevel);
 
-window.less = less = require('./non-node-index.js')(environment);
+window.less = less = require('../less/index.js')(environment);
 
 less.env = options.env || (location.hostname == '127.0.0.1' ||
                         location.hostname == '0.0.0.0'   ||
diff --git a/lib/less/environment/node.js b/lib/less-node/environment.js
similarity index 99%
rename from lib/less/environment/node.js
rename to lib/less-node/environment.js
index 9c2f8e9..3340091 100644
--- a/lib/less/environment/node.js
+++ b/lib/less-node/environment.js
@@ -1,7 +1,7 @@
 var path = require('path'),
     url = require('url'),
     request,
-    fs = require('./node/fs'),
+    fs = require('./fs'),
     isUrlRe = /^(?:https?:)?\/\//i;
 
 module.exports = {
diff --git a/lib/less/environment/node/fs.js b/lib/less-node/fs.js
similarity index 100%
rename from lib/less/environment/node/fs.js
rename to lib/less-node/fs.js
diff --git a/lib/less/index.js b/lib/less-node/index.js
similarity index 91%
copy from lib/less/index.js
copy to lib/less-node/index.js
index cb4719f..d624dba 100644
--- a/lib/less/index.js
+++ b/lib/less-node/index.js
@@ -1,5 +1,5 @@
-var environment = require("./environment/node");
-var less = require("./non-node-index.js")(environment);
+var environment = require("./environment.js");
+var less = require("../less/index.js")(environment);
 
 less.formatError = function(ctx, options) {
     options = options || {};
@@ -7,7 +7,7 @@ less.formatError = function(ctx, options) {
     var message = "";
     var extract = ctx.extract;
     var error = [];
-    var stylize = options.color ? require('./lessc_helper').stylize : function (str) { return str; };
+    var stylize = options.color ? require('./lessc-helper').stylize : function (str) { return str; };
 
     // only output a stack if it isn't a less error
     if (ctx.stack && !ctx.type) { return stylize(ctx.stack, 'red'); }
diff --git a/lib/less/lessc_helper.js b/lib/less-node/lessc-helper.js
similarity index 100%
rename from lib/less/lessc_helper.js
rename to lib/less-node/lessc-helper.js
diff --git a/lib/less/environment/api.js b/lib/less/environment/api.js
index 74f0dcc..ef3dee2 100644
--- a/lib/less/environment/api.js
+++ b/lib/less/environment/api.js
@@ -9,7 +9,7 @@ module.exports = {
     /**
       * gets the path from the filename, e.g. "http://wwe.files.com/ha/ha.less" would return
       * "http://wwe.files.com/ha/"
-      * If the filename is a file e.g. "file.less" it should return the empty string ""      
+      * If the filename is a file e.g. "file.less" it should return the empty string ""
       * @param {Object} env - the environment or options object
       * @param {String} filename - the filename to extract the path.
       * @returns {String}
@@ -32,11 +32,11 @@ module.exports = {
       * @param {Function} callback - a function to callback when finished,
       *                   taking the format callback(error, contents, fullfilename, reserved)
       *                   where error is { type: {string}, message: {string} }, contents is {string} and fullfilename is {string}
-      *                   for reserved, see browser.js which uses this argument for cache information
+      *                   for reserved, see less-browser/index.js which uses this argument for cache information
       * @returns {Boolean}
       */
     loadFile: function(env, filename, currentDirectory, callback) {
     },
     supportsDataURI: function(env) {
     }
-};
\ No newline at end of file
+};
diff --git a/lib/less/index.js b/lib/less/index.js
index cb4719f..2b2ed2b 100644
--- a/lib/less/index.js
+++ b/lib/less/index.js
@@ -1,60 +1,15 @@
-var environment = require("./environment/node");
-var less = require("./non-node-index.js")(environment);
-
-less.formatError = function(ctx, options) {
-    options = options || {};
-
-    var message = "";
-    var extract = ctx.extract;
-    var error = [];
-    var stylize = options.color ? require('./lessc_helper').stylize : function (str) { return str; };
-
-    // only output a stack if it isn't a less error
-    if (ctx.stack && !ctx.type) { return stylize(ctx.stack, 'red'); }
-
-    if (!ctx.hasOwnProperty('index') || !extract) {
-        return ctx.stack || ctx.message;
-    }
-
-    if (typeof(extract[0]) === 'string') {
-        error.push(stylize((ctx.line - 1) + ' ' + extract[0], 'grey'));
-    }
-
-    if (typeof(extract[1]) === 'string') {
-        var errorTxt = ctx.line + ' ';
-        if (extract[1]) {
-            errorTxt += extract[1].slice(0, ctx.column) +
-                            stylize(stylize(stylize(extract[1].substr(ctx.column, 1), 'bold') +
-                            extract[1].slice(ctx.column + 1), 'red'), 'inverse');
-        }
-        error.push(errorTxt);
-    }
-
-    if (typeof(extract[2]) === 'string') {
-        error.push(stylize((ctx.line + 1) + ' ' + extract[2], 'grey'));
-    }
-    error = error.join('\n') + stylize('', 'reset') + '\n';
-
-    message += stylize(ctx.type + 'Error: ' + ctx.message, 'red');
-    if (ctx.filename) {
-        message += stylize(' in ', 'red') + ctx.filename +
-            stylize(' on line ' + ctx.line + ', column ' + (ctx.column + 1) + ':', 'grey');
-    }
-
-    message += '\n' + error;
-
-    if (ctx.callLine) {
-        message += stylize('from ', 'red') + (ctx.filename || '') + '/n';
-        message += stylize(ctx.callLine, 'grey') + ' ' + ctx.callExtract + '/n';
-    }
-
-    return message;
+module.exports = function(environment) {
+    var less = {
+        version: [2, 0, 0],
+        data: require('./data/index.js'),
+        tree: require('./tree/index.js'),
+        visitor: require('./visitor/index.js'),
+        Parser: require('./parser/parser.js'),
+        functions: require('./functions/index.js')(environment),
+        contexts: require("./contexts.js"),
+        environment: environment
+    };
+    less.render = require("./render.js")(environment);
+
+    return less;
 };
-
-less.writeError = function (ctx, options) {
-    options = options || {};
-    if (options.silent) { return; }
-    console.error(less.formatError(ctx, options));
-};
-
-module.exports = less;
diff --git a/lib/less/non-node-index.js b/lib/less/non-node-index.js
deleted file mode 100644
index 2b2ed2b..0000000
--- a/lib/less/non-node-index.js
+++ /dev/null
@@ -1,15 +0,0 @@
-module.exports = function(environment) {
-    var less = {
-        version: [2, 0, 0],
-        data: require('./data/index.js'),
-        tree: require('./tree/index.js'),
-        visitor: require('./visitor/index.js'),
-        Parser: require('./parser/parser.js'),
-        functions: require('./functions/index.js')(environment),
-        contexts: require("./contexts.js"),
-        environment: environment
-    };
-    less.render = require("./render.js")(environment);
-
-    return less;
-};
diff --git a/test/index.js b/test/index.js
index ab28110..600df98 100644
--- a/test/index.js
+++ b/test/index.js
@@ -1,7 +1,7 @@
 var lessTest = require("./less-test"),
     lessTester = lessTest(),
     path = require("path"),
-    stylize = require('../lib/less/lessc_helper').stylize;
+    stylize = require('../lib/less-node/lessc-helper').stylize;
 
 function getErrorPathReplacementFunction(dir) {
     return function(input) {
diff --git a/test/less-test.js b/test/less-test.js
index 9d2a0db..2da185c 100644
--- a/test/less-test.js
+++ b/test/less-test.js
@@ -4,8 +4,8 @@ module.exports = function() {
     var path = require('path'),
         fs = require('fs');
 
-    var less = require('../lib/less');
-    var stylize = require('../lib/less/lessc_helper').stylize;
+    var less = require('../lib/less-node');
+    var stylize = require('../lib/less-node/lessc-helper').stylize;
 
     var globals = Object.keys(global);
 

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