Fix lint errors and add tests for @import (plugin)

This commit is contained in:
rjgotten
2015-02-26 14:40:36 +01:00
parent 39c6aa65f3
commit d96af08795
6 changed files with 22 additions and 6 deletions

View File

@@ -17,7 +17,7 @@ PluginLoader.prototype.tryImportPlugin = function(resolvedFileName) {
}
if (plugin.minVersion) {
if (this.compareVersion(plugin.minVersion, this.less.version) < 0) {
console.log("plugin " + name + " requires version " + this.versionToString(plugin.minVersion));
console.log("plugin at" + resolvedFileName + " requires version " + this.versionToString(plugin.minVersion));
return null;
}
}

View File

@@ -15,9 +15,10 @@ abstractFileManager.prototype.getPath = function (filename) {
}
return filename.slice(0, j + 1);
};
abstractFileManager.prototype.tryAppendExtension = function(path, ext) {
return /(\.[a-z]*$)|([\?;].*)$/.test(path) ? path : path + ext;
}
};
abstractFileManager.prototype.tryAppendLessExtension = function(path) {
return this.tryAppendExtension(path, '.less');

View File

@@ -65,10 +65,10 @@ module.exports = function(environment) {
}
if (importOptions.plugin) {
path = fileManager.tryAppendExtension(path, '.js');
var resolvedFilename = !fileManager.isPathAbsolute(path)
? fileManager.join(currentFileInfo.currentDirectory, path)
: path;
var resolvedFilename = fileManager.tryAppendExtension(path, '.js');
if (!fileManager.isPathAbsolute(path)) {
resolvedFilename = fileManager.join(currentFileInfo.currentDirectory, resolvedFilename);
}
try {
this.context.pluginManager.importPlugin(resolvedFilename);
fileParsedFunc(null, "", resolvedFilename);