Fix 'meteor add' output for nonexistent packages/versions.

Fixes #2898.
This commit is contained in:
Emily Stark
2014-10-29 22:19:31 -07:00
parent f3cc623615
commit 25951b3fb8
2 changed files with 31 additions and 2 deletions

View File

@@ -2094,15 +2094,22 @@ main.registerCommand({
}
_.each(constraints, function (constraint) {
var thisConstraintFailed = false;
// Check that the package exists.
doOrDie({title: 'Checking package: ' + constraint.name }, function () {
if (! catalog.complete.getPackage(constraint.name)) {
Console.error(constraint.name + ": no such package");
failed = true;
thisConstraintFailed = true;
return;
}
});
if (thisConstraintFailed) {
failed = true;
return;
}
// If the version was specified, check that the version exists.
_.each(constraint.constraints, function (constr) {
if (constr.version !== null) {
@@ -2112,11 +2119,17 @@ main.registerCommand({
if (! versionInfo) {
Console.stderr.write(
constraint.name + "@" + constr.version + ": no such version\n");
failed = true;
thisConstraintFailed = true;
return;
}
}
});
if (thisConstraintFailed) {
failed = true;
return;
}
// Check that the constraint is new. If we are already using the package at
// the same constraint in the app, return from this function, but don't
// fail. Rejecting the entire command because a part of it is a no-op is

View File

@@ -285,6 +285,13 @@ selftest.define("add packages to app", ["net"], function () {
run.matchErr("no such version");
run.expectExit(1);
// Adding a nonexistent package at a nonexistent version should print
// only one error message, not two. (We used to print "no such
// package" and "no such version".)
run = s.run("add", "not-a-real-package-and-never-will-be@1.0.0");
run.matchErr("no such package");
run.expectExit(1);
run.forbidAll("no such version");
run = s.run("add", "accounts-base");
@@ -294,6 +301,15 @@ selftest.define("add packages to app", ["net"], function () {
checkPackages(s,
["meteor-platform", "accounts-base"]);
// Adding the nonexistent version now should still say "no such
// version". Regression test for
// https://github.com/meteor/meteor/issues/2898.
run = s.run("add", "accounts-base@0.123.123");
run.matchErr("no such version");
run.expectExit(1);
run.forbidAll("Currently using accounts-base");
run.forbidAll("will be changed to");
run = s.run("--once");
run = s.run("add", "say-something@1.0.0");