From 576468eae8d8dd7c1fe2fa381ac51dee5cb792cd Mon Sep 17 00:00:00 2001 From: Ben Newman Date: Sun, 17 Jul 2016 12:50:13 -0400 Subject: [PATCH] Handle more errors in ensureDevBundleLink. If a developer tried to `meteor update` a project whose `.meteor/release` file corresponded to a version of `meteor-tool` that no longer exists in `~/.meteor/packages/meteor-tool`, this code would throw an ENOENT error. This could be fixed by running `meteor update --release ` first, but that kind of workaround shouldn't be necessary when updating Meteor to the latest version. --- tools/project-context.js | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/tools/project-context.js b/tools/project-context.js index d1d7b01d45..341f3d8343 100644 --- a/tools/project-context.js +++ b/tools/project-context.js @@ -1399,7 +1399,12 @@ _.extend(exports.ReleaseFile.prototype, { } } - return files.realpath(devBundle); + try { + return files.realpath(devBundle); + } catch (e) { + if (e.code !== "ENOENT") throw e; + return null; + } }, // Make a symlink from .meteor/local/dev_bundle to the actual dev_bundle. @@ -1422,9 +1427,10 @@ _.extend(exports.ReleaseFile.prototype, { return; } - files.mkdir_p(localDir); - const newTarget = this.getDevBundle(); + if (! newTarget) { + return; + } try { const oldOSPath = readLink(devBundleLink); @@ -1435,15 +1441,16 @@ _.extend(exports.ReleaseFile.prototype, { return; } + files.mkdir_p(localDir); + makeLink(newTarget, devBundleLink); + } catch (e) { if (e.code !== "ENOENT") { - // It's ok if files.realpath(devBundleLink) failed because the - // devBundleLink file does not exist. + // It's ok if the above commands failed because the target path + // did not exist, but other errors should not be silenced. throw e; } } - - makeLink(newTarget, devBundleLink); }, write: function (releaseName) {