From fba76a3eaef95ef336ba84ecb6d199424f754aad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20Carrasco=20Mo=C3=B1ino?= Date: Thu, 24 Jun 2021 13:20:41 +0200 Subject: [PATCH] chore: fix last version when the list have more than 9 versions (#1845) --- scripts/lib/versions.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/scripts/lib/versions.js b/scripts/lib/versions.js index 6f5041a55b9..9702aeadee6 100755 --- a/scripts/lib/versions.js +++ b/scripts/lib/versions.js @@ -111,7 +111,11 @@ async function getLatestNpmVersion(package, version, major, minor) { if (!cachedNpmVersions[package]) { cmd = `npm view ${package} versions --json`; const json = await JSON.parse(await run(cmd)) - const versions = json.filter(version => version.startsWith(`${major}.${minor}`)); + const versions = json + .filter(version => version.startsWith(`${major}.${minor}`)) + .map(a => a.replace(/\d+$/, n => +n+900000)) + .sort() + .map(a => a.replace(/\d+$/, n => +n-900000)); const next = versions.pop(); console.log(`Checking next Npm version for ${package} ${version} ${next}`); cachedNpmVersions[package] = next;