better error if published source has no handler

This commit is contained in:
David Glasser
2015-06-30 01:38:37 -07:00
parent 05366ab5c2
commit ef04a21dfd
7 changed files with 58 additions and 4 deletions

View File

@@ -47,6 +47,11 @@ _.extend(exports.CompilerPluginProcessor.prototype, {
return new PackageSourceBatch(unibuild, self);
});
// If we failed to match sources with processors, we're done.
if (buildmessage.jobHasMessages()) {
return [];
}
// Find out which files go with which CompilerPlugins.
_.each(sourceBatches, function (sourceBatch) {
_.each(sourceBatch.resourceSlots, function (resourceSlot) {
@@ -384,7 +389,8 @@ var PackageSourceBatch = function (unibuild, processor) {
self.processor = processor;
var sourceProcessorsByExtension =
self._getSourceProcessorsByExtension();
self.resourceSlots = _.map(unibuild.resources, function (resource) {
self.resourceSlots = [];
unibuild.resources.forEach(function (resource) {
var sourceProcessor = null;
if (resource.type === "source") {
var extension = resource.extension;
@@ -394,11 +400,15 @@ var PackageSourceBatch = function (unibuild, processor) {
} else if (_.has(sourceProcessorsByExtension, extension)) {
sourceProcessor = sourceProcessorsByExtension[extension];
} else {
// XXX BBP better error handling
throw Error("no plugin found for " + JSON.stringify(resource));
buildmessage.error(
`no plugin found for ${ resource.path } in ` +
`${ unibuild.pkg.displayName() }; a plugin for *.${ extension } ` +
`was active when it was published but none is now`);
return;
// recover by ignoring
}
}
return new ResourceSlot(resource, sourceProcessor, self);
self.resourceSlots.push(new ResourceSlot(resource, sourceProcessor, self));
});
};
_.extend(PackageSourceBatch.prototype, {

View File

@@ -0,0 +1 @@
local

View File

@@ -0,0 +1,7 @@
# This file contains a token that is unique to your project.
# Check it into your repository along with the rest of this directory.
# It can be used for purposes such as:
# - ensuring you don't accidentally deploy one app on top of another
# - providing package authors with aggregated statistics
140b34e2hn59de0acc2

View File

@@ -0,0 +1,8 @@
# Meteor packages used by this project, one per line.
#
# 'meteor add' and 'meteor remove' will edit this file for you,
# but you can also edit it by hand.
meteor-platform
local-plugin
glasser:use-sourcish@=0.0.1

View File

@@ -0,0 +1,3 @@
Package.describe({
version: '1.0.0'
});

View File

@@ -216,3 +216,27 @@ selftest.define("compiler plugins - duplicate extension", () => {
run.stop();
});
// Test error when a source file no longer has an active plugin.
selftest.define("compiler plugins - inactive source", () => {
const s = new Sandbox({ fakeMongo: true });
// This app depends on the published package 'glasser:uses-sourcish', and
// contains a local package 'local-plugin'.
//
// glasser:uses-sourcish depends on local-plugin and contains a file
// 'foo.sourcish'. When glasser:uses-sourcish@0.0.1 was published, a local
// copy of 'local-plugin' had a plugin which called registerCompiler for the
// extension '*.sourcish', and so 'foo.sourcish' is in the published isopack
// as a source file. However, the copy of 'local-plugin' currently in the test
// app contains no plugins. So we hit this weird error.
s.createApp('myapp', 'uses-published-package-with-inactive-source');
s.cd('myapp');
let run = startRun(s);
run.match('Errors prevented startup');
run.match('no plugin found for foo.sourcish in glasser:use-sourcish');
run.match('none is now');
run.stop();
});