0
Fork 0
mirror of https://github.com/withastro/astro.git synced 2024-12-16 21:46:22 -05:00

Fix non-stable versions for astro add (#12095)

This commit is contained in:
Reuben Tier 2024-10-01 07:18:30 +01:00 committed by GitHub
parent 12dae50c77
commit 76c5fbd6f3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 7 additions and 1 deletions

View file

@ -0,0 +1,5 @@
---
'astro': patch
---
Fix installing non-stable versions of integrations with `astro add`

View file

@ -608,7 +608,8 @@ async function resolveRangeToInstallSpecifier(name: string, range: string): Prom
if (versions instanceof Error) return name; if (versions instanceof Error) return name;
// Filter out any prerelease versions, but fallback if there are no stable versions // Filter out any prerelease versions, but fallback if there are no stable versions
const stableVersions = versions.filter((v) => !v.includes('-')); const stableVersions = versions.filter((v) => !v.includes('-'));
const maxStable = maxSatisfying(stableVersions.length !== 0 ? stableVersions : versions, range); const maxStable = maxSatisfying(stableVersions, range) ?? maxSatisfying(versions, range);
if (!maxStable) return name;
return `${name}@^${maxStable}`; return `${name}@^${maxStable}`;
} }