mirror of
https://github.com/meteor/meteor.git
synced 2026-05-02 03:01:46 -04:00
less: better error for unknown @import
also, fix coffee/less self-test
This commit is contained in:
@@ -2,7 +2,6 @@ var fs = Npm.require('fs');
|
||||
var path = Npm.require('path');
|
||||
var less = Npm.require('less');
|
||||
var util = Npm.require('util');
|
||||
var path = Npm.require('path');
|
||||
var Future = Npm.require('fibers/future');
|
||||
var LRU = Npm.require('lru-cache');
|
||||
|
||||
@@ -222,21 +221,24 @@ _.extend(MeteorImportLessFileManager.prototype, {
|
||||
}
|
||||
var currentPackagePrefix = packageMatch[1];
|
||||
|
||||
var resolvedFilename;
|
||||
if (filename[0] === '/') {
|
||||
// Map `/foo/bar.less` onto `{thispackage}/foo/bar.less`
|
||||
filename = currentPackagePrefix + filename;
|
||||
} else if (filename[0] !== '{') {
|
||||
filename = path.join(currentDirectory, filename);
|
||||
resolvedFilename = currentPackagePrefix + filename;
|
||||
} else if (filename[0] === '{') {
|
||||
resolvedFilename = filename;
|
||||
} else {
|
||||
resolvedFilename = path.join(currentDirectory, filename);
|
||||
}
|
||||
if (! _.has(self.filesByAbsoluteImportPath, filename)) {
|
||||
if (! _.has(self.filesByAbsoluteImportPath, resolvedFilename)) {
|
||||
// XXX BBP better error handling?
|
||||
cb({type: "File", message: "Unknown import: " + filename});
|
||||
return;
|
||||
}
|
||||
cb(null, {
|
||||
contents: self.filesByAbsoluteImportPath[filename]
|
||||
contents: self.filesByAbsoluteImportPath[resolvedFilename]
|
||||
.getContentsAsBuffer().toString('utf8'),
|
||||
filename: filename
|
||||
filename: resolvedFilename
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -135,6 +135,9 @@ _.extend(InputFile.prototype, {
|
||||
getSourceHash: function () {
|
||||
return this._resourceSlot.inputResource.hash;
|
||||
},
|
||||
getExtension: function () {
|
||||
return this._resourceSlot.inputResource.extension;
|
||||
},
|
||||
|
||||
/**
|
||||
* @summary Returns a list of symbols declared as exports in this target. The
|
||||
|
||||
@@ -706,12 +706,12 @@ _.extend(Isopack.prototype, {
|
||||
// If a package is depending on a package that provides a minifier plugin,
|
||||
// the minifier plugin is not used anywhere.
|
||||
_doNotCallThisDirectly_registerMinifier: function (options, factory) {
|
||||
var badUsedExtenssion = _.find(options.extensions, function (ext) {
|
||||
var badUsedExtension = _.find(options.extensions, function (ext) {
|
||||
return ! _.contains(['js', 'css'], ext);
|
||||
});
|
||||
|
||||
if (badUsedExtenssion !== undefined) {
|
||||
buildmessage.error(badUsedExtenssion + ': Minifiers are only allowed to register "css" or "js" extensions.');
|
||||
if (badUsedExtension !== undefined) {
|
||||
buildmessage.error(badUsedExtension + ': Minifiers are only allowed to register "css" or "js" extensions.');
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -7,3 +7,4 @@ meteor-platform
|
||||
coffeescript
|
||||
less
|
||||
local-pack
|
||||
standard-minifiers
|
||||
|
||||
@@ -142,6 +142,11 @@ selftest.define("compiler plugin caching - coffee/less", function () {
|
||||
run.match('Coffeescript X is 2 Y is edited FromPackage is 5');
|
||||
checkCSS(expectedBorderStyles);
|
||||
|
||||
s.write('bad-import.main.less', '@import "/foo/bad.less";\n');
|
||||
run.match('Errors prevented startup');
|
||||
run.match('bad-import.main.less:1: Unknown import: /foo/bad.less');
|
||||
run.match('Waiting for file change');
|
||||
|
||||
run.stop();
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user