From 78b24a2b15e5ec38b24227915139c4bb58b278a5 Mon Sep 17 00:00:00 2001 From: Trevor Scheer Date: Mon, 18 Sep 2023 14:34:26 -0700 Subject: [PATCH] Wait for dist-tag updates to finish The logs from the `update-next-tags` script indicate that things aren't correctly being waited on. Some logs are missing entirely. Some packages don't get their appropriate update. This change should at least get us the logs if it doesn't fix the issue itself. --- scripts/update-next-tags.mjs | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/scripts/update-next-tags.mjs b/scripts/update-next-tags.mjs index aa50617b7..f06f8f582 100644 --- a/scripts/update-next-tags.mjs +++ b/scripts/update-next-tags.mjs @@ -1,10 +1,13 @@ // @ts-check import { exec } from "child_process"; +import { promisify } from "util"; import { readFileSync } from "fs"; import fetch from "node-fetch"; import { resolve } from "path"; import semver from "semver"; +const asyncExec = promisify(exec); + let statusCode = 0; // Collect all the packages that we publish const workspaces = JSON.parse( @@ -37,14 +40,14 @@ await Promise.all( const command = `npm dist-tag add ${pkg}@${mostRecentVersion} next`; if (nextVersion !== mostRecentVersion) { console.log(`\`next\` tag is behind, updating...`); - exec(command, (e) => { - if (e) { - console.error(e); - throw e; - } else { - console.log("`next` tag updated successfully!"); - } - }); + try { + const { stdout, stderr } = await asyncExec(command) + if (stderr) console.error(stderr); + if (stdout) console.log(stdout); + } catch (e) { + console.error(e); + throw e; + } } else { console.log( "No action needed, `next` tag is pointed to most recent version"