mirror of
https://github.com/less/less.js.git
synced 2026-05-01 03:00:22 -04:00
Remove Node / Browserify 'path' module dependency
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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));
|
||||
|
||||
Reference in New Issue
Block a user