[Pkg-javascript-commits] [less.js] 165/285: some renames, tidy ups and bugfixes whilst adding npm plugin

Jonas Smedegaard dr at jones.dk
Mon Oct 26 23:23:50 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 b966cf1d1b273ee1c553a9c193603e50ad4887da
Author: Luke Page <luke.a.page at gmail.com>
Date:   Sat Oct 11 17:51:08 2014 +0100

    some renames, tidy ups and bugfixes whilst adding npm plugin
---
 lib/less-browser/{browser-import.js => file-manager.js} | 16 ++++++++--------
 lib/less-browser/index.js                               | 10 ++++++----
 lib/less-node/{file-import.js => file-manager.js}       | 14 +++++++-------
 lib/less-node/index.js                                  | 10 +++++-----
 lib/less-node/{url-import.js => url-file-manager.js}    | 10 +++++-----
 lib/less/environment/abstract-file-manager.js           |  4 ++--
 6 files changed, 33 insertions(+), 31 deletions(-)

diff --git a/lib/less-browser/browser-import.js b/lib/less-browser/file-manager.js
similarity index 86%
rename from lib/less-browser/browser-import.js
rename to lib/less-browser/file-manager.js
index e5279c0..cf1cc50 100644
--- a/lib/less-browser/browser-import.js
+++ b/lib/less-browser/file-manager.js
@@ -24,21 +24,21 @@ function getXMLHttpRequest() {
     }
 }
 
-var BrowserImport = function() {
+var FileManager = function() {
 };
 
-BrowserImport.prototype = new AbstractFileManager();
+FileManager.prototype = new AbstractFileManager();
 
-BrowserImport.prototype.alwaysMakePathsAbsolute = function alwaysMakePathsAbsolute() {
+FileManager.prototype.alwaysMakePathsAbsolute = function alwaysMakePathsAbsolute() {
     return true;
 };
-BrowserImport.prototype.join = function join(basePath, laterPath) {
+FileManager.prototype.join = function join(basePath, laterPath) {
     if (!basePath) {
         return laterPath;
     }
     return this.extractUrlParts(laterPath, basePath).path;
 };
-BrowserImport.prototype.doXHR = function doXHR(url, type, callback, errback) {
+FileManager.prototype.doXHR = function doXHR(url, type, callback, errback) {
 
     var xhr = getXMLHttpRequest();
     var async = isFileProtocol ? options.fileAsync : options.async;
@@ -76,11 +76,11 @@ BrowserImport.prototype.doXHR = function doXHR(url, type, callback, errback) {
         handleResponse(xhr, callback, errback);
     }
 };
-BrowserImport.prototype.supports = function(filename, currentDirectory, options, environment) {
+FileManager.prototype.supports = function(filename, currentDirectory, options, environment) {
     return true;
 };
 
-BrowserImport.prototype.loadFile = function loadFile(filename, currentDirectory, options, environment) {
+FileManager.prototype.loadFile = function loadFile(filename, currentDirectory, options, environment) {
     return new PromiseConstructor(function(fullfill, reject) {
         if (currentDirectory && !this.isPathAbsolute(filename)) {
             filename = currentDirectory + filename;
@@ -115,5 +115,5 @@ BrowserImport.prototype.loadFile = function loadFile(filename, currentDirectory,
     }.bind(this));
 };
 
-return new BrowserImport();
+return FileManager;
 };
diff --git a/lib/less-browser/index.js b/lib/less-browser/index.js
index 656ee9e..fcad374 100644
--- a/lib/less-browser/index.js
+++ b/lib/less-browser/index.js
@@ -16,8 +16,10 @@ var isFileProtocol = /^(file|chrome(-extension)?|resource|qrc|app):/.test(window
 
 window.less = less = require('../less')();
 var environment = less.environment,
-    browserImport = require("./browser-import")(options, isFileProtocol, less.logger);
-environment.addFileManager(browserImport);
+    FileManager = require("./file-manager")(options, isFileProtocol, less.logger),
+    fileManager = new FileManager();
+environment.addFileManager(fileManager);
+less.FileManager = FileManager;
 
 require("./log-listener")(less, options);
 //var utils = require("./utils");
@@ -129,7 +131,7 @@ function loadStyleSheet(sheet, callback, reload, remaining, modifyVars) {
         instanceOptions.useFileCache = true;
     }
 
-    browserImport.loadFile(sheet.href, null, instanceOptions, environment)
+    fileManager.loadFile(sheet.href, null, instanceOptions, environment)
     .then(function loadInitialFileCallback(loadedFile) {
 
        var data = loadedFile.contents,
@@ -137,7 +139,7 @@ function loadStyleSheet(sheet, callback, reload, remaining, modifyVars) {
            webInfo = loadedFile.webInfo;
 
         var newFileInfo = {
-            currentDirectory: browserImport.getPath(path),
+            currentDirectory: fileManager.getPath(path),
             filename: path,
             rootFilename: path,
             relativeUrls: instanceOptions.relativeUrls};
diff --git a/lib/less-node/file-import.js b/lib/less-node/file-manager.js
similarity index 82%
rename from lib/less-node/file-import.js
rename to lib/less-node/file-manager.js
index 84734b7..a3c27fe 100644
--- a/lib/less-node/file-import.js
+++ b/lib/less-node/file-manager.js
@@ -3,19 +3,19 @@ var path = require('path'),
     PromiseConstructor = typeof Promise === 'undefined' ? require('promise') : Promise,
     AbstractFileManager = require("../less/environment/abstract-file-manager.js");
 
-var FileImport = function() {
+var FileManager = function() {
 };
 
-FileImport.prototype = new AbstractFileManager();
+FileManager.prototype = new AbstractFileManager();
 
-FileImport.prototype.supports = function(filename, currentDirectory, options, environment) {
+FileManager.prototype.supports = function(filename, currentDirectory, options, environment) {
     return true;
 };
-FileImport.prototype.supportsSync = function(filename, currentDirectory, options, environment) {
+FileManager.prototype.supportsSync = function(filename, currentDirectory, options, environment) {
     return true;
 };
 
-FileImport.prototype.loadFile = function(filename, currentDirectory, options, environment) {
+FileManager.prototype.loadFile = function(filename, currentDirectory, options, environment) {
     return new PromiseConstructor(function(fullfill, reject) {
         var fullFilename,
             data;
@@ -71,9 +71,9 @@ FileImport.prototype.loadFile = function(filename, currentDirectory, options, en
     });
 };
 
-FileImport.prototype.loadFileSync = function(filename, currentDirectory, options, environment) {
+FileManager.prototype.loadFileSync = function(filename, currentDirectory, options, environment) {
     filename = path.join(currentDirectory, filename);
     return { contents: fs.readFileSync(filename), filename: filename };
 };
 
-module.exports = new FileImport();
+module.exports = FileManager;
diff --git a/lib/less-node/index.js b/lib/less-node/index.js
index ce94a18..d29a35e 100644
--- a/lib/less-node/index.js
+++ b/lib/less-node/index.js
@@ -1,8 +1,8 @@
 var environment = require("./environment"),
-    fileImport = require("./file-import.js"),
-    urlImport = require("./url-import.js"),
+    FileManager = require("./file-manager"),
+    UrlFileManager = require("./url-file-manager"),
     createFromEnvironment = require("../less"),
-    less = createFromEnvironment(environment, [fileImport, urlImport]),
+    less = createFromEnvironment(environment, [new FileManager(), new UrlFileManager()]),
     lesscHelper = require('./lessc-helper');
 
 // allow people to create less with their own environment
@@ -10,8 +10,8 @@ less.createFromEnvironment = createFromEnvironment;
 less.lesscHelper = lesscHelper;
 less.PluginLoader = require("./plugin-loader");
 less.fs = require("./fs");
-less.fileImport = require("./file-import.js");
-less.urlImport = require("./url-import.js");
+less.FileManager = FileManager;
+less.UrlFileManager = UrlFileManager;
 less.formatError = function(ctx, options) {
     options = options || {};
 
diff --git a/lib/less-node/url-import.js b/lib/less-node/url-file-manager.js
similarity index 84%
rename from lib/less-node/url-import.js
rename to lib/less-node/url-file-manager.js
index 63a2041..9548c7e 100644
--- a/lib/less-node/url-import.js
+++ b/lib/less-node/url-file-manager.js
@@ -5,16 +5,16 @@ var isUrlRe = /^(?:https?:)?\/\//i,
     AbstractFileManager = require("../less/environment/abstract-file-manager.js"),
     logger = require("../less/logger");
 
-var UrlImport = function() {
+var UrlFileManager = function() {
 };
 
-UrlImport.prototype = new AbstractFileManager();
+UrlFileManager.prototype = new AbstractFileManager();
 
-UrlImport.prototype.supports = function(filename, currentDirectory, options, environment) {
+UrlFileManager.prototype.supports = function(filename, currentDirectory, options, environment) {
     return isUrlRe.test( filename ) || isUrlRe.test(currentDirectory);
 };
 
-UrlImport.prototype.loadFile = function(filename, currentDirectory, options, environment) {
+UrlFileManager.prototype.loadFile = function(filename, currentDirectory, options, environment) {
     return new PromiseConstructor(function(fullfill, reject) {
         if (request === undefined) {
             try { request = require('request'); }
@@ -50,4 +50,4 @@ UrlImport.prototype.loadFile = function(filename, currentDirectory, options, env
     });
 };
 
-module.exports = new UrlImport();
+module.exports = UrlFileManager;
diff --git a/lib/less/environment/abstract-file-manager.js b/lib/less/environment/abstract-file-manager.js
index 1ca31b2..e5e218d 100644
--- a/lib/less/environment/abstract-file-manager.js
+++ b/lib/less/environment/abstract-file-manager.js
@@ -70,7 +70,7 @@ abstractFileManager.prototype.extractUrlParts = function extractUrlParts(url, ba
     }
 
     // Stylesheets in IE don't always return the full path
-    if (!urlParts[1] || urlParts[2]) {
+    if (baseUrl && (!urlParts[1] || urlParts[2])) {
         baseUrlParts = baseUrl.match(urlPartsRegex);
         if (!baseUrlParts) {
             throw new Error("Could not parse page url - '"+baseUrl+"'");
@@ -102,7 +102,7 @@ abstractFileManager.prototype.extractUrlParts = function extractUrlParts(url, ba
 
     returner.hostPart = urlParts[1];
     returner.directories = directories;
-    returner.path = urlParts[1] + directories.join("/");
+    returner.path = (urlParts[1] || "") + directories.join("/");
     returner.fileUrl = returner.path + (urlParts[4] || "");
     returner.url = returner.fileUrl + (urlParts[5] || "");
     return returner;

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