From 006d4a6e78030332c453308909d877e7c22b3c7f Mon Sep 17 00:00:00 2001 From: David Bushong Date: Fri, 4 Jan 2019 12:35:05 -0800 Subject: [PATCH] fix: wrap risky co.wrap yields Unlike real async/await, the yields you use with co.wrap explode if you don't hand them a real Promise. Let's just wrap the risky ones at their point-of-use to make it easy to strip them back off when we port to real async/await in the future. --- lib/commands/changelog.js | 2 +- lib/commands/release.js | 2 +- lib/commands/verify.js | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/commands/changelog.js b/lib/commands/changelog.js index 239f38a..f07e8a7 100644 --- a/lib/commands/changelog.js +++ b/lib/commands/changelog.js @@ -53,7 +53,7 @@ const showChangelog = co.wrap(function*(cwd, pkg, options) { const tasks = [ensureVersionTag, getPendingChanges, generateChangeLog]; - for (const task of tasks) yield runTask(task); + for (const task of tasks) yield Promise.resolve(runTask(task)); return printChangelog(); }); diff --git a/lib/commands/release.js b/lib/commands/release.js index 3714edf..a0dea94 100644 --- a/lib/commands/release.js +++ b/lib/commands/release.js @@ -97,7 +97,7 @@ function release(cwd, pkg, options) { publishTasks = [publishToNpm]; } - for (const task of publishTasks) yield runTask(task); + for (const task of publishTasks) yield Promise.resolve(runTask(task)); return null; }); diff --git a/lib/commands/verify.js b/lib/commands/verify.js index 93e7efc..7917ed4 100644 --- a/lib/commands/verify.js +++ b/lib/commands/verify.js @@ -102,11 +102,11 @@ function verify(cwd, pkg, options) { ]; function runTask(task) { - return Promise.resolve(task(cwd, pkg, options)); + return task(cwd, pkg, options); } const runVerifyTasks = co.wrap(function*() { - for (const task of verifyTasks) yield runTask(task); + for (const task of verifyTasks) yield Promise.resolve(runTask(task)); }); return runVerifyTasks();