diff --git a/tools/isobuild/package-source.js b/tools/isobuild/package-source.js index ba135dca6b..6588f42fc7 100644 --- a/tools/isobuild/package-source.js +++ b/tools/isobuild/package-source.js @@ -609,8 +609,11 @@ _.extend(PackageSource.prototype, { } else if (key === "prodOnly") { self.prodOnly = !!value; } else { - // Do nothing. We might want to add some keys later, and we should err - // on the side of backwards compatibility. + // Do nothing. We might want to add some keys later, and we should err + // on the side of backwards compatibility. + } + if (self.debugOnly && self.prodOnly) { + buildmessage.error("Package can't have both debugOnly and prodOnly set."); } }); }, diff --git a/tools/tests/package-tests.js b/tools/tests/package-tests.js index e961990b2f..341b81a281 100644 --- a/tools/tests/package-tests.js +++ b/tools/tests/package-tests.js @@ -263,8 +263,7 @@ selftest.define("change packages during hot code push", [], function () { }); // Add packages through the command line. Make sure that the correct set of -// changes is reflected in .meteor/packages, .meteor/versions and list. Make -// sure that debugOnly packages don't show up in production mode. +// changes is reflected in .meteor/packages, .meteor/versions and list. selftest.define("add packages to app", [], function () { var s = new Sandbox(); var run; @@ -352,8 +351,18 @@ selftest.define("add packages to app", [], function () { run.match("no-description\n"); run.expectEnd(); run.expectExit(0); +}); - // Add a debugOnly package. It should work during a normal run, but print +selftest.define("add debugOnly and prodOnly packages", [], function () { + var s = new Sandbox(); + var run; + + // Starting a run + s.createApp("myapp", "package-tests"); + s.cd("myapp"); + s.set("METEOR_OFFLINE_CATALOG", "t"); + + // Add a debugOnly package. It should work during a normal run, but print // nothing in production mode. run = s.run("add", "debug-only"); run.match("debug-only"); @@ -389,6 +398,20 @@ selftest.define("add packages to app", [], function () { run.expectExit(234); }); +selftest.define("add package with both debugOnly and prodOnly", [], function () { + var s = new Sandbox(); + var run; + + // Add an app with a package with prodOnly and debugOnly set (an error) + s.createApp("myapp", "debug-only-test", {dontPrepareApp: true}); + s.cd("myapp"); + run = s.run("--prepare-app"); + run.waitSecs(20); + run.matchErr("can't have both debugOnly and prodOnly"); + run.expectExit(1); +}); + + // Add a package that adds files to specific client architectures. selftest.define("add packages client archs", function (options) { var runTestWithArgs = function (clientType, args, port) {