Remove Node / Browserify 'path' module dependency

This commit is contained in:
Matthew Dean
2016-07-16 20:45:46 -07:00
parent 54affb852b
commit 3d9f8433d1
2 changed files with 9 additions and 7 deletions

View File

@@ -116,6 +116,7 @@ abstractFileManager.prototype.extractUrlParts = function extractUrlParts(url, ba
returner.hostPart = urlParts[1];
returner.directories = directories;
returner.path = (urlParts[1] || "") + directories.join("/");
returner.filename = urlParts[4];
returner.fileUrl = returner.path + (urlParts[4] || "");
returner.url = returner.fileUrl + (urlParts[5] || "");
return returner;

View File

@@ -32,11 +32,13 @@ AbstractPluginLoader.prototype.evalPlugin = function(contents, context, pluginOp
filename = fileInfo.filename;
}
}
var shortname = (new this.less.FileManager()).extractUrlParts(filename).filename;
if (filename) {
pluginObj = pluginManager.get(filename);
if (pluginObj) {
this.trySetOptions(pluginObj, filename, pluginOptions);
this.trySetOptions(pluginObj, filename, shortname, pluginOptions);
if (pluginObj.use) {
pluginObj.use.call(this.context, pluginObj);
}
@@ -58,14 +60,14 @@ AbstractPluginLoader.prototype.evalPlugin = function(contents, context, pluginOp
if (!pluginObj) {
pluginObj = localModule.exports;
}
pluginObj = this.validatePlugin(pluginObj, filename);
pluginObj = this.validatePlugin(pluginObj, filename, shortname);
if (pluginObj) {
// Run on first load
pluginManager.addPlugin(pluginObj, fileInfo.filename, registry);
pluginObj.functions = registry.getLocalFunctions();
this.trySetOptions(pluginObj, filename, pluginOptions);
this.trySetOptions(pluginObj, filename, shortname, pluginOptions);
// Run every @plugin call
if (pluginObj.use) {
@@ -91,8 +93,7 @@ AbstractPluginLoader.prototype.evalPlugin = function(contents, context, pluginOp
};
AbstractPluginLoader.prototype.trySetOptions = function(plugin, filename, options) {
var name = require('path').basename(filename);
AbstractPluginLoader.prototype.trySetOptions = function(plugin, filename, name, options) {
if (options) {
if (!plugin.setOptions) {
error("Options have been provided but the plugin " + name + " does not support any options.");
@@ -108,14 +109,14 @@ AbstractPluginLoader.prototype.trySetOptions = function(plugin, filename, option
}
};
AbstractPluginLoader.prototype.validatePlugin = function(plugin, filename) {
AbstractPluginLoader.prototype.validatePlugin = function(plugin, filename, name) {
if (plugin) {
// support plugins being a function
// so that the plugin can be more usable programmatically
if (typeof plugin === "function") {
plugin = new plugin();
}
var name = require('path').basename(filename);
if (plugin.minVersion) {
if (this.compareVersion(plugin.minVersion, this.less.version) < 0) {
error("Plugin " + name + " requires version " + this.versionToString(plugin.minVersion));