From 72a0ef541f04897a34b6c1f9644d4a225f0c26c0 Mon Sep 17 00:00:00 2001 From: Isaac Mann Date: Mon, 5 May 2025 20:34:01 -0400 Subject: [PATCH] chore(core): fix docs release script for single version (#31060) Fixes an issue with the docs release script when there is only one version in a particular major version. The `npm show [version] --json` command normally returns an array of strings, but if there is only one version returned, it tries to be helpful by returning a string instead. This fix normalizes that behavior. --- scripts/release-docs.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/scripts/release-docs.ts b/scripts/release-docs.ts index 0569352e5d..44e483c485 100644 --- a/scripts/release-docs.ts +++ b/scripts/release-docs.ts @@ -11,11 +11,14 @@ const currentVersion = process.env.GITHUB_REF_NAME || ''; console.log(`Comparing ${currentVersion} to npm versions`); const majorVersion = major(currentVersion); -const releasedVersions: string[] = JSON.parse( +let releasedVersions: string[] = JSON.parse( execSync(`npm show nx@^${majorVersion} version --json`, { windowsHide: false, }).toString() ); +if (typeof releasedVersions === 'string') { + releasedVersions = [releasedVersions]; +} const latestVersion = maxSatisfying(releasedVersions, `^${majorVersion}`);