Fix plugin issues

This commit is contained in:
Luke Page
2014-10-09 18:21:31 +01:00
parent a344240423
commit c0f60cccf8
3 changed files with 16 additions and 7 deletions

View File

@@ -227,7 +227,7 @@ args = args.filter(function (arg) {
if (plugin) {
plugins.push(plugin);
} else {
console.log("Unable to load plugin " + name + " please make sure that it is installed under at the same level as less");
console.log("Unable to load plugin " + name + " please make sure that it is installed under or at the same level as less");
console.log();
printUsage();
currentErrorcode = 1;
@@ -238,7 +238,7 @@ args = args.filter(function (arg) {
if (plugin) {
plugins.push(plugin);
} else {
console.log("Unable to interpret argument " + arg + " - if it is a plugin (less-plugin-" + arg + "), make sure that it is installed under at the same level as less");
console.log("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");
console.log();
printUsage();
currentErrorcode = 1;

View File

@@ -12,11 +12,20 @@ PluginLoader.prototype.tryLoadPlugin = function(name, argument) {
console.log("plugin " + name + " requires version " + this.versionToString(plugin.minVersion));
return null;
}
} else {
console.log("plugin has no min version");
}
if (argument) {
plugin.setOptions(argument);
if (!plugin.setOptions) {
console.log("options have been provided but the plugin " + name + "does not support any options");
return null;
}
try {
plugin.setOptions(argument);
}
catch(e) {
console.log("Error setting options on plugin " + name);
console.log(e.message);
return null;
}
}
return plugin;
}

View File

@@ -13,7 +13,7 @@ module.exports = function(environment, ParseTree, ImportManager) {
}
if (callback) {
render(input, options)
render.call(this, input, options)
.then(function(css) {
callback(null, css);
},
@@ -23,7 +23,7 @@ module.exports = function(environment, ParseTree, ImportManager) {
} else {
var context,
rootFileInfo,
pluginManager = new PluginManager();
pluginManager = new PluginManager(this);
pluginManager.addPlugins(options.plugins);
options.pluginManager = pluginManager;