mirror of
https://github.com/less/less.js.git
synced 2026-05-01 03:00:22 -04:00
Plugin loader set up for lessc, node, and browser
This commit is contained in:
4
.jscsrc
4
.jscsrc
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"disallowImplicitTypeConversion": ["numeric", "boolean", "binary", "string"],
|
||||
"disallowImplicitTypeConversion": ["numeric", "binary", "string"],
|
||||
"disallowKeywords": ["with"],
|
||||
"disallowMixedSpacesAndTabs": true,
|
||||
"disallowMultipleLineBreaks": true,
|
||||
@@ -14,7 +14,7 @@
|
||||
"disallowSpacesInNamedFunctionExpression": {
|
||||
"beforeOpeningRoundBrace": true},
|
||||
"disallowTrailingComma": true,
|
||||
"disallowTrailingWhitespace": true,
|
||||
"disallowTrailingWhitespace": false,
|
||||
"maximumLineLength": 160,
|
||||
"requireCommaBeforeLineBreak": true,
|
||||
"requireCurlyBraces": [ "if",
|
||||
|
||||
462
bin/lessc
462
bin/lessc
@@ -14,31 +14,43 @@ try {
|
||||
|
||||
var less = require('../lib/less-node'),
|
||||
pluginLoader = new less.PluginLoader(less),
|
||||
plugin,
|
||||
plugins = [];
|
||||
|
||||
var args = process.argv.slice(1);
|
||||
var silent = false,
|
||||
plugins = [],
|
||||
queuePlugins = [],
|
||||
args = process.argv.slice(1),
|
||||
silent = false,
|
||||
verbose = false,
|
||||
options = {
|
||||
depends: false,
|
||||
compress: false,
|
||||
max_line_len: -1,
|
||||
lint: false,
|
||||
paths: [],
|
||||
color: true,
|
||||
strictImports: false,
|
||||
insecure: false,
|
||||
rootpath: '',
|
||||
relativeUrls: false,
|
||||
ieCompat: true,
|
||||
strictMath: false,
|
||||
strictUnits: false,
|
||||
globalVars: null,
|
||||
modifyVars: null,
|
||||
urlArgs: '',
|
||||
plugins: plugins
|
||||
};
|
||||
depends: false,
|
||||
compress: false,
|
||||
max_line_len: -1,
|
||||
lint: false,
|
||||
paths: [],
|
||||
color: true,
|
||||
strictImports: false,
|
||||
insecure: false,
|
||||
rootpath: '',
|
||||
relativeUrls: false,
|
||||
ieCompat: true,
|
||||
strictMath: false,
|
||||
strictUnits: false,
|
||||
globalVars: null,
|
||||
modifyVars: null,
|
||||
urlArgs: '',
|
||||
plugins: plugins
|
||||
};
|
||||
|
||||
if (less.options) {
|
||||
for (var i = 0, keys = Object.keys(options); i < keys.length; i++) {
|
||||
if (!less.options[keys[i]]) {
|
||||
less.options[keys[i]] = options[keys[i]];
|
||||
}
|
||||
}
|
||||
options = less.options;
|
||||
}
|
||||
else {
|
||||
less.options = options;
|
||||
}
|
||||
|
||||
var sourceMapOptions = {};
|
||||
var continueProcessing = true;
|
||||
|
||||
@@ -94,194 +106,7 @@ function printUsage() {
|
||||
pluginLoader.printUsage(plugins);
|
||||
continueProcessing = false;
|
||||
}
|
||||
|
||||
// self executing function so we can return
|
||||
(function() {
|
||||
args = args.filter(function (arg) {
|
||||
var match;
|
||||
|
||||
match = arg.match(/^-I(.+)$/);
|
||||
if (match) {
|
||||
options.paths.push(match[1]);
|
||||
return false;
|
||||
}
|
||||
|
||||
match = arg.match(/^--?([a-z][0-9a-z-]*)(?:=(.*))?$/i);
|
||||
if (match) {
|
||||
arg = match[1];
|
||||
} else {
|
||||
return arg;
|
||||
}
|
||||
|
||||
switch (arg) {
|
||||
case 'v':
|
||||
case 'version':
|
||||
console.log("lessc " + less.version.join('.') + " (Less Compiler) [JavaScript]");
|
||||
continueProcessing = false;
|
||||
break;
|
||||
case 'verbose':
|
||||
verbose = true;
|
||||
break;
|
||||
case 's':
|
||||
case 'silent':
|
||||
silent = true;
|
||||
break;
|
||||
case 'l':
|
||||
case 'lint':
|
||||
options.lint = true;
|
||||
break;
|
||||
case 'strict-imports':
|
||||
options.strictImports = true;
|
||||
break;
|
||||
case 'h':
|
||||
case 'help':
|
||||
printUsage();
|
||||
break;
|
||||
case 'x':
|
||||
case 'compress':
|
||||
options.compress = true;
|
||||
break;
|
||||
case 'insecure':
|
||||
options.insecure = true;
|
||||
break;
|
||||
case 'M':
|
||||
case 'depends':
|
||||
options.depends = true;
|
||||
break;
|
||||
case 'max-line-len':
|
||||
if (checkArgFunc(arg, match[2])) {
|
||||
options.maxLineLen = parseInt(match[2], 10);
|
||||
if (options.maxLineLen <= 0) {
|
||||
options.maxLineLen = -1;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 'no-color':
|
||||
options.color = false;
|
||||
break;
|
||||
case 'no-ie-compat':
|
||||
options.ieCompat = false;
|
||||
break;
|
||||
case 'no-js':
|
||||
options.javascriptEnabled = false;
|
||||
break;
|
||||
case 'include-path':
|
||||
if (checkArgFunc(arg, match[2])) {
|
||||
// ; supported on windows.
|
||||
// : supported on windows and linux, excluding a drive letter like C:\ so C:\file:D:\file parses to 2
|
||||
options.paths = match[2]
|
||||
.split(os.type().match(/Windows/) ? /:(?!\\)|;/ : ':')
|
||||
.map(function(p) {
|
||||
if (p) {
|
||||
return path.resolve(process.cwd(), p);
|
||||
}
|
||||
});
|
||||
}
|
||||
break;
|
||||
case 'line-numbers':
|
||||
if (checkArgFunc(arg, match[2])) {
|
||||
options.dumpLineNumbers = match[2];
|
||||
}
|
||||
break;
|
||||
case 'source-map':
|
||||
options.sourceMap = true;
|
||||
if (match[2]) {
|
||||
sourceMapOptions.sourceMapFullFilename = match[2];
|
||||
}
|
||||
break;
|
||||
case 'source-map-rootpath':
|
||||
if (checkArgFunc(arg, match[2])) {
|
||||
sourceMapOptions.sourceMapRootpath = match[2];
|
||||
}
|
||||
break;
|
||||
case 'source-map-basepath':
|
||||
if (checkArgFunc(arg, match[2])) {
|
||||
sourceMapOptions.sourceMapBasepath = match[2];
|
||||
}
|
||||
break;
|
||||
case 'source-map-map-inline':
|
||||
sourceMapFileInline = true;
|
||||
options.sourceMap = true;
|
||||
break;
|
||||
case 'source-map-less-inline':
|
||||
sourceMapOptions.outputSourceFiles = true;
|
||||
break;
|
||||
case 'source-map-url':
|
||||
if (checkArgFunc(arg, match[2])) {
|
||||
sourceMapOptions.sourceMapURL = match[2];
|
||||
}
|
||||
break;
|
||||
case 'rp':
|
||||
case 'rootpath':
|
||||
if (checkArgFunc(arg, match[2])) {
|
||||
options.rootpath = match[2].replace(/\\/g, '/');
|
||||
}
|
||||
break;
|
||||
case "ru":
|
||||
case "relative-urls":
|
||||
options.relativeUrls = true;
|
||||
break;
|
||||
case "sm":
|
||||
case "strict-math":
|
||||
if (checkArgFunc(arg, match[2])) {
|
||||
options.strictMath = checkBooleanArg(match[2]);
|
||||
}
|
||||
break;
|
||||
case "su":
|
||||
case "strict-units":
|
||||
if (checkArgFunc(arg, match[2])) {
|
||||
options.strictUnits = checkBooleanArg(match[2]);
|
||||
}
|
||||
break;
|
||||
case "global-var":
|
||||
if (checkArgFunc(arg, match[2])) {
|
||||
if (!options.globalVars) {
|
||||
options.globalVars = {};
|
||||
}
|
||||
parseVariableOption(match[2], options.globalVars);
|
||||
}
|
||||
break;
|
||||
case "modify-var":
|
||||
if (checkArgFunc(arg, match[2])) {
|
||||
if (!options.modifyVars) {
|
||||
options.modifyVars = {};
|
||||
}
|
||||
|
||||
parseVariableOption(match[2], options.modifyVars);
|
||||
}
|
||||
break;
|
||||
case 'url-args':
|
||||
if (checkArgFunc(arg, match[2])) {
|
||||
options.urlArgs = match[2];
|
||||
}
|
||||
break;
|
||||
case 'plugin':
|
||||
var splitupArg = match[2].match(/^([^=]+)(=(.*))?/),
|
||||
name = splitupArg[1],
|
||||
pluginOptions = splitupArg[3];
|
||||
|
||||
plugin = pluginLoader.tryLoadPlugin(name, pluginOptions);
|
||||
if (plugin) {
|
||||
plugins.push(plugin);
|
||||
} else {
|
||||
console.error("Unable to load plugin " + name +
|
||||
" please make sure that it is installed under or at the same level as less");
|
||||
process.exitCode = 1;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
plugin = pluginLoader.tryLoadPlugin("less-plugin-" + arg, match[2]);
|
||||
if (plugin) {
|
||||
plugins.push(plugin);
|
||||
} else {
|
||||
console.error("Unable to interpret argument " + arg +
|
||||
" - if it is a plugin (less-plugin-" + arg + "), make sure that it is installed under or at" +
|
||||
" the same level as less");
|
||||
process.exitCode = 1;
|
||||
}
|
||||
break;
|
||||
}
|
||||
});
|
||||
function render() {
|
||||
|
||||
if (!continueProcessing) {
|
||||
return;
|
||||
@@ -505,4 +330,219 @@ function printUsage() {
|
||||
parseLessFile(false, buffer);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function processPluginQueue() {
|
||||
var x = 0;
|
||||
|
||||
function pluginError(name) {
|
||||
console.error("Unable to load plugin " + name +
|
||||
" please make sure that it is installed under or at the same level as less");
|
||||
process.exitCode = 1;
|
||||
}
|
||||
function pluginFinished(plugin) {
|
||||
x++;
|
||||
plugins.push(plugin);
|
||||
if (x === queuePlugins.length) {
|
||||
render();
|
||||
}
|
||||
}
|
||||
queuePlugins.forEach(function(queue) {
|
||||
pluginLoader.tryLoadPlugin(queue.name, function(err, data) {
|
||||
if (err) {
|
||||
pluginError(queue.name);
|
||||
}
|
||||
else {
|
||||
pluginFinished({
|
||||
fileContent: data.contents,
|
||||
filename: data.filename,
|
||||
options: queue.options
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// self executing function so we can return
|
||||
(function() {
|
||||
args = args.filter(function (arg) {
|
||||
var match;
|
||||
|
||||
match = arg.match(/^-I(.+)$/);
|
||||
if (match) {
|
||||
options.paths.push(match[1]);
|
||||
return false;
|
||||
}
|
||||
|
||||
match = arg.match(/^--?([a-z][0-9a-z-]*)(?:=(.*))?$/i);
|
||||
if (match) {
|
||||
arg = match[1];
|
||||
} else {
|
||||
return arg;
|
||||
}
|
||||
|
||||
switch (arg) {
|
||||
case 'v':
|
||||
case 'version':
|
||||
console.log("lessc " + less.version.join('.') + " (Less Compiler) [JavaScript]");
|
||||
continueProcessing = false;
|
||||
break;
|
||||
case 'verbose':
|
||||
verbose = true;
|
||||
break;
|
||||
case 's':
|
||||
case 'silent':
|
||||
silent = true;
|
||||
break;
|
||||
case 'l':
|
||||
case 'lint':
|
||||
options.lint = true;
|
||||
break;
|
||||
case 'strict-imports':
|
||||
options.strictImports = true;
|
||||
break;
|
||||
case 'h':
|
||||
case 'help':
|
||||
printUsage();
|
||||
break;
|
||||
case 'x':
|
||||
case 'compress':
|
||||
options.compress = true;
|
||||
break;
|
||||
case 'insecure':
|
||||
options.insecure = true;
|
||||
break;
|
||||
case 'M':
|
||||
case 'depends':
|
||||
options.depends = true;
|
||||
break;
|
||||
case 'max-line-len':
|
||||
if (checkArgFunc(arg, match[2])) {
|
||||
options.maxLineLen = parseInt(match[2], 10);
|
||||
if (options.maxLineLen <= 0) {
|
||||
options.maxLineLen = -1;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 'no-color':
|
||||
options.color = false;
|
||||
break;
|
||||
case 'no-ie-compat':
|
||||
options.ieCompat = false;
|
||||
break;
|
||||
case 'inline-js':
|
||||
options.javascriptEnabled = true;
|
||||
break;
|
||||
case 'no-js':
|
||||
console.error('The "--no-js" argument is deprecated. Use "--inline-js" to enable inline JavaScript.');
|
||||
break;
|
||||
case 'include-path':
|
||||
if (checkArgFunc(arg, match[2])) {
|
||||
// ; supported on windows.
|
||||
// : supported on windows and linux, excluding a drive letter like C:\ so C:\file:D:\file parses to 2
|
||||
options.paths = match[2]
|
||||
.split(os.type().match(/Windows/) ? /:(?!\\)|;/ : ':')
|
||||
.map(function(p) {
|
||||
if (p) {
|
||||
return path.resolve(process.cwd(), p);
|
||||
}
|
||||
});
|
||||
}
|
||||
break;
|
||||
case 'line-numbers':
|
||||
if (checkArgFunc(arg, match[2])) {
|
||||
options.dumpLineNumbers = match[2];
|
||||
}
|
||||
break;
|
||||
case 'source-map':
|
||||
options.sourceMap = true;
|
||||
if (match[2]) {
|
||||
sourceMapOptions.sourceMapFullFilename = match[2];
|
||||
}
|
||||
break;
|
||||
case 'source-map-rootpath':
|
||||
if (checkArgFunc(arg, match[2])) {
|
||||
sourceMapOptions.sourceMapRootpath = match[2];
|
||||
}
|
||||
break;
|
||||
case 'source-map-basepath':
|
||||
if (checkArgFunc(arg, match[2])) {
|
||||
sourceMapOptions.sourceMapBasepath = match[2];
|
||||
}
|
||||
break;
|
||||
case 'source-map-map-inline':
|
||||
sourceMapFileInline = true;
|
||||
options.sourceMap = true;
|
||||
break;
|
||||
case 'source-map-less-inline':
|
||||
sourceMapOptions.outputSourceFiles = true;
|
||||
break;
|
||||
case 'source-map-url':
|
||||
if (checkArgFunc(arg, match[2])) {
|
||||
sourceMapOptions.sourceMapURL = match[2];
|
||||
}
|
||||
break;
|
||||
case 'rp':
|
||||
case 'rootpath':
|
||||
if (checkArgFunc(arg, match[2])) {
|
||||
options.rootpath = match[2].replace(/\\/g, '/');
|
||||
}
|
||||
break;
|
||||
case "ru":
|
||||
case "relative-urls":
|
||||
options.relativeUrls = true;
|
||||
break;
|
||||
case "sm":
|
||||
case "strict-math":
|
||||
if (checkArgFunc(arg, match[2])) {
|
||||
options.strictMath = checkBooleanArg(match[2]);
|
||||
}
|
||||
break;
|
||||
case "su":
|
||||
case "strict-units":
|
||||
if (checkArgFunc(arg, match[2])) {
|
||||
options.strictUnits = checkBooleanArg(match[2]);
|
||||
}
|
||||
break;
|
||||
case "global-var":
|
||||
if (checkArgFunc(arg, match[2])) {
|
||||
if (!options.globalVars) {
|
||||
options.globalVars = {};
|
||||
}
|
||||
parseVariableOption(match[2], options.globalVars);
|
||||
}
|
||||
break;
|
||||
case "modify-var":
|
||||
if (checkArgFunc(arg, match[2])) {
|
||||
if (!options.modifyVars) {
|
||||
options.modifyVars = {};
|
||||
}
|
||||
|
||||
parseVariableOption(match[2], options.modifyVars);
|
||||
}
|
||||
break;
|
||||
case 'url-args':
|
||||
if (checkArgFunc(arg, match[2])) {
|
||||
options.urlArgs = match[2];
|
||||
}
|
||||
break;
|
||||
case 'plugin':
|
||||
var splitupArg = match[2].match(/^([^=]+)(=(.*))?/),
|
||||
name = splitupArg[1],
|
||||
pluginOptions = splitupArg[3];
|
||||
queuePlugins.push({ name: name, options: pluginOptions });
|
||||
break;
|
||||
default:
|
||||
queuePlugins.push({ name: arg, options: match[2], default: true });
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
if (queuePlugins.length > 0) {
|
||||
processPluginQueue();
|
||||
}
|
||||
else {
|
||||
render();
|
||||
}
|
||||
|
||||
})();
|
||||
|
||||
@@ -9,7 +9,7 @@ module.exports = function(window, options) {
|
||||
var document = window.document;
|
||||
var less = require('../less')();
|
||||
|
||||
//module.exports = less;
|
||||
options.javascriptEnabled = !!(options.javascriptEnabled || options.inlineJavaScript);
|
||||
less.options = options;
|
||||
var environment = less.environment,
|
||||
FileManager = require("./file-manager")(options, less.logger),
|
||||
@@ -23,20 +23,13 @@ module.exports = function(window, options) {
|
||||
var cache = less.cache = options.cache || require("./cache")(window, options, less.logger);
|
||||
require('./image-size')(less.environment);
|
||||
|
||||
//Setup user functions
|
||||
//Setup user functions - Deprecate?
|
||||
if (options.functions) {
|
||||
less.functions.functionRegistry.addMultiple(options.functions);
|
||||
}
|
||||
|
||||
var typePattern = /^text\/(x-)?less$/;
|
||||
|
||||
function postProcessCSS(styles) { // deprecated, use a plugin for postprocesstasks
|
||||
if (options.postProcessor && typeof options.postProcessor === 'function') {
|
||||
styles = options.postProcessor.call(styles, styles) || styles;
|
||||
}
|
||||
return styles;
|
||||
}
|
||||
|
||||
function clone(obj) {
|
||||
var cloned = {};
|
||||
for (var prop in obj) {
|
||||
@@ -133,7 +126,6 @@ module.exports = function(window, options) {
|
||||
e.href = path;
|
||||
callback(e);
|
||||
} else {
|
||||
result.css = postProcessCSS(result.css);
|
||||
cache.setCSS(sheet.href, webInfo.lastModified, instanceOptions.modifyVars, result.css);
|
||||
callback(null, result.css, data, sheet, webInfo, path);
|
||||
}
|
||||
|
||||
@@ -11,24 +11,49 @@ var PluginLoader = function(less) {
|
||||
|
||||
PluginLoader.prototype = new AbstractPluginLoader();
|
||||
|
||||
PluginLoader.prototype.tryLoadFromEnvironment = function(filename, basePath, callback) {
|
||||
|
||||
if(basePath && !filename) {
|
||||
filename = path.join(basePath, name);
|
||||
}
|
||||
if(filename) {
|
||||
var fileManager = new this.less.FileManager();
|
||||
|
||||
filename = fileManager.tryAppendExtension(filename,'.js');
|
||||
fileManager.loadFile(filename).then(
|
||||
function(data) {
|
||||
PluginLoader.prototype.tryLoadPlugin = function(name, argument, basePath, callback) {
|
||||
var self = this;
|
||||
var prefix = name.slice(0, 1);
|
||||
var explicit = prefix === "." || prefix === "/" || name.slice(-3).toLowerCase() === ".js";
|
||||
this.tryLoadFromEnvironment(name, basePath, explicit, function(err, data) {
|
||||
if (explicit) {
|
||||
callback(err, data);
|
||||
}
|
||||
else {
|
||||
if (!err) {
|
||||
callback(null, data);
|
||||
},
|
||||
|
||||
function(err) {
|
||||
callback(err);
|
||||
}
|
||||
);
|
||||
else {
|
||||
self.tryLoadFromEnvironment('less-plugin-' + name, basePath, explicit, function(err2, data) {
|
||||
callback(err, data);
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
};
|
||||
|
||||
PluginLoader.prototype.tryLoadFromEnvironment = function(filename, basePath, explicit, callback) {
|
||||
var fileManager;
|
||||
|
||||
if (basePath) {
|
||||
filename = path.join(basePath, filename);
|
||||
}
|
||||
|
||||
if (filename) {
|
||||
fileManager = new this.less.FileManager();
|
||||
|
||||
filename = fileManager.tryAppendExtension(filename, '.js');
|
||||
|
||||
var done = function(err, data) {
|
||||
if (err) {
|
||||
callback(err);
|
||||
} else {
|
||||
callback(null, data);
|
||||
}
|
||||
};
|
||||
fileManager.loadFile(filename, null, null, null, done);
|
||||
|
||||
}
|
||||
else {
|
||||
callback({ message: 'Plugin could not be found.'});
|
||||
|
||||
@@ -12,6 +12,9 @@ less.PluginLoader = require("./plugin-loader");
|
||||
less.fs = require("./fs");
|
||||
less.FileManager = FileManager;
|
||||
less.UrlFileManager = UrlFileManager;
|
||||
less.options = less.options || {};
|
||||
less.options.javascriptEnabled = false;
|
||||
|
||||
less.formatError = function(ctx, options) {
|
||||
options = options || {};
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ var lessc_helper = {
|
||||
console.log(" -M, --depends Outputs a makefile import dependency list to stdout.");
|
||||
console.log(" --no-color Disables colorized output.");
|
||||
console.log(" --no-ie-compat Disables IE compatibility checks.");
|
||||
console.log(" --no-js Disables JavaScript in less files");
|
||||
console.log(" --inline-js Enables inline JavaScript in less files");
|
||||
console.log(" -l, --lint Syntax check only (lint).");
|
||||
console.log(" -s, --silent Suppresses output of error messages.");
|
||||
console.log(" --strict-imports Forces evaluation of imports.");
|
||||
|
||||
@@ -11,54 +11,49 @@ var PluginLoader = function(less) {
|
||||
prefix = path.dirname(prefix);
|
||||
return function(id) {
|
||||
var str = id.substr(0, 2);
|
||||
if(str === '..' || str === './') {
|
||||
if (str === '..' || str === './') {
|
||||
return require(path.join(prefix, id));
|
||||
}
|
||||
else {
|
||||
return require(id);
|
||||
}
|
||||
}
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
PluginLoader.prototype = new AbstractPluginLoader();
|
||||
|
||||
PluginLoader.prototype.tryLoadFromEnvironment = function(name, basePath, callback) {
|
||||
PluginLoader.prototype.tryLoadPlugin = function(name, basePath, callback) {
|
||||
var self = this;
|
||||
var prefix = name.slice(0, 1);
|
||||
var explicit = prefix === "." || prefix === "/" || name.slice(-3).toLowerCase() === ".js";
|
||||
if (explicit) {
|
||||
this.tryLoadFromEnvironment(name, basePath, explicit, callback);
|
||||
}
|
||||
else {
|
||||
this.tryLoadFromEnvironment('less-plugin-' + name, basePath, explicit, function(err, data) {
|
||||
if (!err) {
|
||||
callback(null, data);
|
||||
}
|
||||
else {
|
||||
self.tryLoadFromEnvironment(name, basePath, explicit, function(err2, data2) {
|
||||
callback(err2, data2);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
PluginLoader.prototype.tryLoadFromEnvironment = function(name, basePath, explicit, callback) {
|
||||
var filename;
|
||||
var self = this;
|
||||
|
||||
try {
|
||||
filename = require.resolve(path.join("../../../", name));
|
||||
}
|
||||
catch(e) {
|
||||
}
|
||||
// is installed as a sub dependency of the current folder
|
||||
try {
|
||||
filename = require.resolve(path.join(process.cwd(), "node_modules", name));
|
||||
}
|
||||
catch(e) {
|
||||
}
|
||||
// is referenced relative to the current directory
|
||||
try {
|
||||
filename = require.resolve(path.join(process.cwd(), name));
|
||||
}
|
||||
catch(e) {
|
||||
}
|
||||
// unlikely - would have to be a dependency of where this code was running (less.js)...
|
||||
if (name[0] !== '.') {
|
||||
try {
|
||||
filename = require.resolve(name);
|
||||
}
|
||||
catch(e) {
|
||||
}
|
||||
}
|
||||
if(basePath && !filename) {
|
||||
filename = path.join(basePath, name);
|
||||
}
|
||||
if(filename) {
|
||||
var fileManager = new this.less.FileManager();
|
||||
function getFile(filename) {
|
||||
|
||||
filename = fileManager.tryAppendExtension(filename,'.js');
|
||||
var fileManager = new self.less.FileManager();
|
||||
|
||||
filename = fileManager.tryAppendExtension(filename, '.js');
|
||||
fileManager.loadFile(filename).then(
|
||||
function(data) {
|
||||
try {
|
||||
@@ -75,8 +70,48 @@ PluginLoader.prototype.tryLoadFromEnvironment = function(name, basePath, callbac
|
||||
}
|
||||
);
|
||||
}
|
||||
if (explicit) {
|
||||
if (basePath) {
|
||||
filename = path.join(basePath, name);
|
||||
}
|
||||
getFile(filename);
|
||||
}
|
||||
else {
|
||||
callback({ message: 'Plugin could not be found.'});
|
||||
// Search node_modules for a possible plugin name match
|
||||
try {
|
||||
filename = require.resolve(path.join("../../../", name));
|
||||
}
|
||||
catch(e) {
|
||||
}
|
||||
// is installed as a sub dependency of the current folder
|
||||
try {
|
||||
filename = require.resolve(path.join(process.cwd(), "node_modules", name));
|
||||
}
|
||||
catch(e) {
|
||||
}
|
||||
// is referenced relative to the current directory
|
||||
try {
|
||||
filename = require.resolve(path.join(process.cwd(), name));
|
||||
}
|
||||
catch(e) {
|
||||
}
|
||||
// unlikely - would have to be a dependency of where this code was running (less.js)...
|
||||
if (name[0] !== '.') {
|
||||
try {
|
||||
filename = require.resolve(name);
|
||||
}
|
||||
catch(e) {
|
||||
}
|
||||
}
|
||||
if (basePath && !filename) {
|
||||
filename = path.join(basePath, name);
|
||||
}
|
||||
if (filename) {
|
||||
getFile(filename);
|
||||
}
|
||||
else {
|
||||
callback({ message: 'Plugin could not be found.'});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
var functionRegistry = require("../functions/function-registry");
|
||||
var functionRegistry = require("../functions/function-registry"),
|
||||
LessError = require('../less-error');
|
||||
|
||||
var AbstractPluginLoader = function() {
|
||||
};
|
||||
|
||||
@@ -10,26 +12,39 @@ function error(msg, type) {
|
||||
}
|
||||
);
|
||||
}
|
||||
AbstractPluginLoader.prototype.evalPlugin = function(contents, context, fileInfo, callback) {
|
||||
AbstractPluginLoader.prototype.evalPlugin = function(contents, context, pluginOptions, fileInfo) {
|
||||
|
||||
var loader,
|
||||
registry,
|
||||
pluginObj,
|
||||
localModule,
|
||||
localExports;
|
||||
localExports,
|
||||
pluginManager,
|
||||
filename;
|
||||
|
||||
pluginManager = context.pluginManager;
|
||||
|
||||
pluginObj = context.pluginManager.get(fileInfo.filename);
|
||||
|
||||
if(pluginObj) {
|
||||
if(pluginObj.use) {
|
||||
pluginObj.use(this.less);
|
||||
if (fileInfo) {
|
||||
if (typeof fileInfo === "string") {
|
||||
filename = fileInfo;
|
||||
}
|
||||
else {
|
||||
filename = fileInfo.filename;
|
||||
}
|
||||
return callback(null, pluginObj);
|
||||
}
|
||||
localModule = {
|
||||
if (filename) {
|
||||
pluginObj = pluginManager.get(filename);
|
||||
|
||||
if (pluginObj) {
|
||||
if (pluginObj.use) {
|
||||
pluginObj.use(this.less);
|
||||
}
|
||||
return pluginObj;
|
||||
}
|
||||
}
|
||||
localModule = {
|
||||
exports: {},
|
||||
pluginManager: context.pluginManager,
|
||||
pluginManager: pluginManager,
|
||||
fileInfo: fileInfo
|
||||
};
|
||||
localExports = localModule.exports;
|
||||
@@ -39,18 +54,18 @@ AbstractPluginLoader.prototype.evalPlugin = function(contents, context, fileInfo
|
||||
loader = new Function("module", "require", "functions", "tree", "fileInfo", "less", contents);
|
||||
pluginObj = loader(localModule, this.require, registry, this.less.tree, fileInfo, this.less);
|
||||
|
||||
if(!pluginObj) {
|
||||
if (!pluginObj) {
|
||||
pluginObj = localModule.exports;
|
||||
}
|
||||
|
||||
pluginObj = this.validatePlugin(pluginObj);
|
||||
if(pluginObj) {
|
||||
pluginObj = this.validatePlugin(pluginObj, filename, pluginOptions);
|
||||
if (pluginObj) {
|
||||
// Run on first load
|
||||
context.pluginManager.addPlugin(pluginObj, fileInfo.filename);
|
||||
pluginManager.addPlugin(pluginObj, fileInfo.filename);
|
||||
pluginObj.functions = registry.getLocalFunctions();
|
||||
|
||||
// Run every @plugin call
|
||||
if(pluginObj.use) {
|
||||
if (pluginObj.use) {
|
||||
pluginObj.use(this.less);
|
||||
}
|
||||
}
|
||||
@@ -61,49 +76,39 @@ AbstractPluginLoader.prototype.evalPlugin = function(contents, context, fileInfo
|
||||
} catch(e) {
|
||||
// TODO pass the error
|
||||
console.log(e.stack.toString());
|
||||
callback(new this.less.LessError({
|
||||
return new this.less.LessError({
|
||||
message: "Plugin evaluation error: '" + e.name + ': ' + e.message.replace(/["]/g, "'") + "'" ,
|
||||
filename: this.fileInfo.filename,
|
||||
filename: filename,
|
||||
line: this.line,
|
||||
col: this.column
|
||||
}), null );
|
||||
});
|
||||
}
|
||||
|
||||
callback(null, pluginObj);
|
||||
return pluginObj;
|
||||
|
||||
};
|
||||
AbstractPluginLoader.prototype.tryLoadPlugin = function(name, argument, basePath, callback) {
|
||||
var self = this;
|
||||
this.tryLoadFromEnvironment(name, basePath, function(err, data) {
|
||||
if(!err) {
|
||||
callback(null, data);
|
||||
}
|
||||
else {
|
||||
self.tryLoadFromEnvironment('less-plugin-' + name, basePath, callback);
|
||||
}
|
||||
});
|
||||
|
||||
};
|
||||
AbstractPluginLoader.prototype.validatePlugin = function(plugin, argument) {
|
||||
AbstractPluginLoader.prototype.validatePlugin = function(plugin, filename, options) {
|
||||
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));
|
||||
return null;
|
||||
}
|
||||
}
|
||||
if (argument) {
|
||||
if (options) {
|
||||
if (!plugin.setOptions) {
|
||||
error("options have been provided but the plugin " + name + "does not support any options");
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
plugin.setOptions(argument);
|
||||
plugin.setOptions(options);
|
||||
}
|
||||
catch(e) {
|
||||
error("Error setting options on plugin " + name + '\n' + e.message);
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
var contexts = require("./contexts"),
|
||||
Parser = require('./parser/parser');
|
||||
Parser = require('./parser/parser'),
|
||||
LessError = require('./less-error');
|
||||
|
||||
module.exports = function(environment) {
|
||||
|
||||
@@ -35,7 +36,7 @@ module.exports = function(environment) {
|
||||
*/
|
||||
ImportManager.prototype.push = function (path, tryAppendExtension, currentFileInfo, importOptions, callback) {
|
||||
var importManager = this,
|
||||
pluginLoader = new this.less.PluginLoader(this.less);
|
||||
pluginLoader = this.context.pluginManager.Loader;
|
||||
|
||||
this.queue.push(path);
|
||||
|
||||
@@ -72,7 +73,8 @@ module.exports = function(environment) {
|
||||
}
|
||||
|
||||
var loadFileCallback = function(loadedFile) {
|
||||
var resolvedFilename = loadedFile.filename,
|
||||
var plugin,
|
||||
resolvedFilename = loadedFile.filename,
|
||||
contents = loadedFile.contents.replace(/^\uFEFF/, '');
|
||||
|
||||
// Pass on an updated rootpath if path of imported file is relative and file
|
||||
@@ -105,9 +107,14 @@ module.exports = function(environment) {
|
||||
}
|
||||
|
||||
if (importOptions.isPlugin) {
|
||||
pluginLoader.evalPlugin(contents, newEnv, newFileInfo, function (e, root) {
|
||||
fileParsedFunc(e, root, resolvedFilename);
|
||||
});
|
||||
|
||||
plugin = pluginLoader.evalPlugin(contents, newEnv, importOptions, newFileInfo);
|
||||
if (plugin instanceof LessError) {
|
||||
fileParsedFunc(plugin, null, resolvedFilename);
|
||||
}
|
||||
else {
|
||||
fileParsedFunc(null, plugin, resolvedFilename);
|
||||
}
|
||||
} else if (importOptions.inline) {
|
||||
fileParsedFunc(null, contents, resolvedFilename);
|
||||
} else {
|
||||
@@ -124,7 +131,7 @@ module.exports = function(environment) {
|
||||
loadFileCallback(loadedFile);
|
||||
}
|
||||
};
|
||||
if(importOptions.isPlugin) {
|
||||
if (importOptions.isPlugin) {
|
||||
// TODO: implement options for plugins
|
||||
try {
|
||||
pluginLoader.tryLoadPlugin(path, null, currentFileInfo.currentDirectory, done);
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
var PromiseConstructor,
|
||||
contexts = require("./contexts"),
|
||||
Parser = require('./parser/parser'),
|
||||
PluginManager = require('./plugin-manager');
|
||||
PluginManager = require('./plugin-manager'),
|
||||
LessError = require('./less-error');
|
||||
|
||||
module.exports = function(environment, ParseTree, ImportManager) {
|
||||
var parse = function (input, options, callback) {
|
||||
@@ -29,10 +30,8 @@ module.exports = function(environment, ParseTree, ImportManager) {
|
||||
} else {
|
||||
var context,
|
||||
rootFileInfo,
|
||||
less = this,
|
||||
pluginManager = new PluginManager(this, true);
|
||||
|
||||
pluginManager.addPlugins(options.plugins);
|
||||
options.pluginManager = pluginManager;
|
||||
|
||||
context = new contexts.Parse(options);
|
||||
@@ -57,7 +56,27 @@ module.exports = function(environment, ParseTree, ImportManager) {
|
||||
}
|
||||
|
||||
var imports = new ImportManager(this, context, rootFileInfo);
|
||||
|
||||
|
||||
if (options.plugins) {
|
||||
options.plugins.forEach(function(plugin) {
|
||||
var evalResult, contents;
|
||||
if (plugin.fileContent) {
|
||||
contents = plugin.fileContent.replace(/^\uFEFF/, '');
|
||||
evalResult = pluginManager.Loader.evalPlugin(contents, context, plugin.options, plugin.filename);
|
||||
if (!(evalResult instanceof LessError)) {
|
||||
pluginManager.addPlugin(plugin);
|
||||
}
|
||||
else {
|
||||
return callback(evalResult);
|
||||
}
|
||||
|
||||
}
|
||||
else {
|
||||
pluginManager.addPlugin(plugin);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
new Parser(context, imports, rootFileInfo)
|
||||
.parse(input, function (e, root) {
|
||||
if (e) { return callback(e); }
|
||||
|
||||
@@ -10,6 +10,7 @@ var PluginManager = function(less) {
|
||||
this.fileManagers = [];
|
||||
this.iterator = -1;
|
||||
this.pluginCache = {};
|
||||
this.Loader = new less.PluginLoader(less);
|
||||
};
|
||||
|
||||
var pm, PluginManagerFactory = function(less, newFactory) {
|
||||
@@ -37,8 +38,10 @@ PluginManager.prototype.addPlugins = function(plugins) {
|
||||
*/
|
||||
PluginManager.prototype.addPlugin = function(plugin, filename) {
|
||||
this.installedPlugins.push(plugin);
|
||||
this.pluginCache[filename] = plugin;
|
||||
if(plugin.install) {
|
||||
if (filename) {
|
||||
this.pluginCache[filename] = plugin;
|
||||
}
|
||||
if (plugin.install) {
|
||||
plugin.install(this.less, this);
|
||||
}
|
||||
};
|
||||
@@ -133,10 +136,10 @@ PluginManager.prototype.visitor = function() {
|
||||
return self.visitors[self.iterator];
|
||||
},
|
||||
get: function() {
|
||||
self.iterator+=1;
|
||||
self.iterator += 1;
|
||||
return self.visitors[self.iterator];
|
||||
}
|
||||
}
|
||||
};
|
||||
};
|
||||
/**
|
||||
*
|
||||
|
||||
@@ -47,8 +47,8 @@ module.exports = function(root, options) {
|
||||
if (options.pluginManager) {
|
||||
visitorIterator = options.pluginManager.visitor();
|
||||
visitorIterator.first();
|
||||
while(v = visitorIterator.get()) {
|
||||
if(v.isPreEvalVisitor) {
|
||||
while ((v = visitorIterator.get())) {
|
||||
if (v.isPreEvalVisitor) {
|
||||
v.run(root);
|
||||
}
|
||||
}
|
||||
@@ -62,7 +62,7 @@ module.exports = function(root, options) {
|
||||
|
||||
if (options.pluginManager) {
|
||||
visitorIterator.first();
|
||||
while(v = visitorIterator.get()) {
|
||||
while ((v = visitorIterator.get())) {
|
||||
v.run(root);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -127,7 +127,7 @@ Import.prototype.doEval = function (context) {
|
||||
features = this.features && this.features.eval(context);
|
||||
|
||||
if (this.options.isPlugin) {
|
||||
if(this.root && this.root.setContext) {
|
||||
if (this.root && this.root.setContext) {
|
||||
this.root.setContext(context);
|
||||
}
|
||||
registry = context.frames[0] && context.frames[0].functionRegistry;
|
||||
|
||||
@@ -11,7 +11,7 @@ JsEvalNode.prototype.evaluateJavaScript = function (expression, context) {
|
||||
evalContext = {};
|
||||
|
||||
if (context.javascriptEnabled !== undefined && !context.javascriptEnabled) {
|
||||
throw { message: "You are using JavaScript, which has been disabled.",
|
||||
throw { message: "Inline JavaScript is not enabled. Is it set in your options?",
|
||||
filename: this.currentFileInfo.filename,
|
||||
index: this.index };
|
||||
}
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
@use "../extension/extension-tree-nodes";
|
||||
@plugin "../plugin/plugin-tree-nodes";
|
||||
test-undefined();
|
||||
@@ -1,3 +1,3 @@
|
||||
SyntaxError: Function 'test-undefined' is undefined in {path}functions-1.less on line 2, column 1:
|
||||
1 @use "../extension/extension-tree-nodes";
|
||||
1 @plugin "../plugin/plugin-tree-nodes";
|
||||
2 test-undefined();
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
@use "../extension/extension-tree-nodes";
|
||||
@plugin "../plugin/plugin-tree-nodes";
|
||||
test-keyword();
|
||||
@@ -1,3 +1,3 @@
|
||||
SyntaxError: Keyword node returned by a function is not valid here in {path}functions-10-keyword.less on line 2, column 1:
|
||||
1 @use "../extension/extension-tree-nodes";
|
||||
1 @plugin "../plugin/plugin-tree-nodes";
|
||||
2 test-keyword();
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
@use "../extension/extension-tree-nodes";
|
||||
@plugin "../plugin/plugin-tree-nodes";
|
||||
test-operation();
|
||||
@@ -1,3 +1,3 @@
|
||||
SyntaxError: Operation node returned by a function is not valid here in {path}functions-11-operation.less on line 2, column 1:
|
||||
1 @use "../extension/extension-tree-nodes";
|
||||
1 @plugin "../plugin/plugin-tree-nodes";
|
||||
2 test-operation();
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
@use "../extension/extension-tree-nodes";
|
||||
@plugin "../plugin/plugin-tree-nodes";
|
||||
test-quoted();
|
||||
@@ -1,3 +1,3 @@
|
||||
SyntaxError: Quoted node returned by a function is not valid here in {path}functions-12-quoted.less on line 2, column 1:
|
||||
1 @use "../extension/extension-tree-nodes";
|
||||
1 @plugin "../plugin/plugin-tree-nodes";
|
||||
2 test-quoted();
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
@use "../extension/extension-tree-nodes";
|
||||
@plugin "../plugin/plugin-tree-nodes";
|
||||
test-selector();
|
||||
@@ -1,3 +1,3 @@
|
||||
SyntaxError: Selector node returned by a function is not valid here in {path}functions-13-selector.less on line 2, column 1:
|
||||
1 @use "../extension/extension-tree-nodes";
|
||||
1 @plugin "../plugin/plugin-tree-nodes";
|
||||
2 test-selector();
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
@use "../extension/extension-tree-nodes";
|
||||
@plugin "../plugin/plugin-tree-nodes";
|
||||
test-url();
|
||||
@@ -1,3 +1,3 @@
|
||||
SyntaxError: Url node returned by a function is not valid here in {path}functions-14-url.less on line 2, column 1:
|
||||
1 @use "../extension/extension-tree-nodes";
|
||||
1 @plugin "../plugin/plugin-tree-nodes";
|
||||
2 test-url();
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
@use "../extension/extension-tree-nodes";
|
||||
@plugin "../plugin/plugin-tree-nodes";
|
||||
test-value();
|
||||
@@ -1,3 +1,3 @@
|
||||
SyntaxError: Value node returned by a function is not valid here in {path}functions-15-value.less on line 2, column 1:
|
||||
1 @use "../extension/extension-tree-nodes";
|
||||
1 @plugin "../plugin/plugin-tree-nodes";
|
||||
2 test-value();
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
@plugin "../extension/extension-tree-nodes";
|
||||
@@ -1,2 +0,0 @@
|
||||
SyntaxError: @plugin is deprecated. Use @use in {path}functions-16-old-syntax.less on line 1, column 1:
|
||||
1 @plugin "../extension/extension-tree-nodes";
|
||||
@@ -1,2 +1,2 @@
|
||||
@use "../extension/extension-tree-nodes";
|
||||
@plugin "../plugin/plugin-tree-nodes";
|
||||
test-alpha();
|
||||
@@ -1,3 +1,3 @@
|
||||
SyntaxError: Alpha node returned by a function is not valid here in {path}functions-2-alpha.less on line 2, column 1:
|
||||
1 @use "../extension/extension-tree-nodes";
|
||||
1 @plugin "../plugin/plugin-tree-nodes";
|
||||
2 test-alpha();
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
@use "../extension/extension-tree-nodes";
|
||||
@plugin "../plugin/plugin-tree-nodes";
|
||||
test-assignment();
|
||||
@@ -1,3 +1,3 @@
|
||||
SyntaxError: Assignment node returned by a function is not valid here in {path}functions-3-assignment.less on line 2, column 1:
|
||||
1 @use "../extension/extension-tree-nodes";
|
||||
1 @plugin "../plugin/plugin-tree-nodes";
|
||||
2 test-assignment();
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
@use "../extension/extension-tree-nodes";
|
||||
@plugin "../plugin/plugin-tree-nodes";
|
||||
test-call();
|
||||
@@ -1,3 +1,3 @@
|
||||
SyntaxError: Function 'foo' is undefined in {path}functions-4-call.less on line 2, column 1:
|
||||
1 @use "../extension/extension-tree-nodes";
|
||||
1 @plugin "../plugin/plugin-tree-nodes";
|
||||
2 test-call();
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
@use "../extension/extension-tree-nodes";
|
||||
@plugin "../plugin/plugin-tree-nodes";
|
||||
test-color();
|
||||
@@ -1,3 +1,3 @@
|
||||
SyntaxError: Color node returned by a function is not valid here in {path}functions-5-color.less on line 2, column 1:
|
||||
1 @use "../extension/extension-tree-nodes";
|
||||
1 @plugin "../plugin/plugin-tree-nodes";
|
||||
2 test-color();
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
@use "../extension/extension-tree-nodes";
|
||||
@plugin "../plugin/plugin-tree-nodes";
|
||||
test-condition();
|
||||
@@ -1,3 +1,3 @@
|
||||
SyntaxError: Condition node returned by a function is not valid here in {path}functions-6-condition.less on line 2, column 1:
|
||||
1 @use "../extension/extension-tree-nodes";
|
||||
1 @plugin "../plugin/plugin-tree-nodes";
|
||||
2 test-condition();
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
@use "../extension/extension-tree-nodes";
|
||||
@plugin "../plugin/plugin-tree-nodes";
|
||||
test-dimension();
|
||||
@@ -1,3 +1,3 @@
|
||||
SyntaxError: Dimension node returned by a function is not valid here in {path}functions-7-dimension.less on line 2, column 1:
|
||||
1 @use "../extension/extension-tree-nodes";
|
||||
1 @plugin "../plugin/plugin-tree-nodes";
|
||||
2 test-dimension();
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
@use "../extension/extension-tree-nodes";
|
||||
@plugin "../plugin/plugin-tree-nodes";
|
||||
test-element();
|
||||
@@ -1,3 +1,3 @@
|
||||
SyntaxError: Element node returned by a function is not valid here in {path}functions-8-element.less on line 2, column 1:
|
||||
1 @use "../extension/extension-tree-nodes";
|
||||
1 @plugin "../plugin/plugin-tree-nodes";
|
||||
2 test-element();
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
@use "../extension/extension-tree-nodes";
|
||||
@plugin "../plugin/plugin-tree-nodes";
|
||||
test-expression();
|
||||
@@ -1,3 +1,3 @@
|
||||
SyntaxError: Expression node returned by a function is not valid here in {path}functions-9-expression.less on line 2, column 1:
|
||||
1 @use "../extension/extension-tree-nodes";
|
||||
1 @plugin "../plugin/plugin-tree-nodes";
|
||||
2 test-expression();
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
@use "../extension/extension-tree-nodes.js";
|
||||
@plugin "../plugin/plugin-tree-nodes.js";
|
||||
test-undefined();
|
||||
@@ -1,3 +1,3 @@
|
||||
SyntaxError: Function 'test-undefined' is undefined in {path}root-func-undefined-2.less on line 2, column 1:
|
||||
1 @use "../extension/extension-tree-nodes.js";
|
||||
1 @plugin "../plugin/plugin-tree-nodes.js";
|
||||
2 test-undefined();
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
// importing plugin globally
|
||||
@use "./extension/extension-global";
|
||||
@plugin "./plugin/plugin-global";
|
||||
|
||||
// transitively include plugins from importing another sheet
|
||||
@import "./extension/extension-transitive";
|
||||
@import "./plugin/plugin-transitive";
|
||||
|
||||
|
||||
// `test-global` function should be reachable
|
||||
@@ -18,7 +18,7 @@
|
||||
// `test-local` function should be reachable
|
||||
// `test-shadow` function should return local version, shadowing global version
|
||||
.local {
|
||||
@use "./extension/extension-local";
|
||||
@plugin "./plugin/plugin-local";
|
||||
global : test-global();
|
||||
local : test-local();
|
||||
shadow : test-shadow();
|
||||
@@ -28,19 +28,19 @@
|
||||
// calling a mixin or detached ruleset should not bubble local plugins
|
||||
// imported inside either into the parent scope.
|
||||
.mixin() {
|
||||
@use "./extension/extension-local";
|
||||
@plugin "./plugin/plugin-local";
|
||||
mixin-local : test-local();
|
||||
mixin-global : test-global();
|
||||
mixin-shadow : test-shadow();
|
||||
}
|
||||
@ruleset : {
|
||||
@use "./extension/extension-local";
|
||||
@plugin "./plugin/plugin-local";
|
||||
ruleset-local : test-local();
|
||||
ruleset-global : test-global();
|
||||
ruleset-shadow : test-shadow();
|
||||
};
|
||||
#ns {
|
||||
@use "./extension/extension-local";
|
||||
@plugin "./plugin/plugin-local";
|
||||
.mixin() {
|
||||
ns-mixin-global : test-global();
|
||||
ns-mixin-local : test-local();
|
||||
@@ -76,12 +76,12 @@
|
||||
|
||||
.test {
|
||||
@media screen {
|
||||
@use "./extension/extension-local";
|
||||
@plugin "./plugin/plugin-local";
|
||||
result : test-local();
|
||||
}
|
||||
}
|
||||
|
||||
@use "./extension/extension-tree-nodes";
|
||||
@plugin "./plugin/plugin-tree-nodes";
|
||||
@ruleset2: test-detached-ruleset();
|
||||
.root {
|
||||
@ruleset2();
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
@use "extension-transitive";
|
||||
@plugin "extension-transitive";
|
||||
|
||||
.other {
|
||||
trans : test-transitive();
|
||||
Reference in New Issue
Block a user