mirror of
https://github.com/withastro/astro.git
synced 2025-01-27 22:19:04 -05:00
Fix: Use ref passed by user to get version in create astro
This commit is contained in:
parent
74ee2e45ec
commit
4a491f23d4
3 changed files with 8 additions and 3 deletions
5
.changeset/selfish-bulldogs-jog.md
Normal file
5
.changeset/selfish-bulldogs-jog.md
Normal file
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
'create-astro': patch
|
||||
---
|
||||
|
||||
Fixes an issue where the `getVersion` function was incorrectly using the `latest` tag instead of the user-specified `ref` to determine the Astro version.
|
|
@ -93,7 +93,7 @@ export async function getContext(argv: string[]): Promise<Context> {
|
|||
prompt,
|
||||
packageManager,
|
||||
username: getName(),
|
||||
version: getVersion(packageManager, 'astro', process.env.ASTRO_VERSION),
|
||||
version: getVersion(packageManager, 'astro', process.env.ASTRO_VERSION, ref),
|
||||
skipHouston,
|
||||
fancy,
|
||||
add,
|
||||
|
|
|
@ -60,10 +60,10 @@ export const getName = () =>
|
|||
});
|
||||
});
|
||||
|
||||
export const getVersion = (packageManager: string, packageName: string, fallback = '') =>
|
||||
export const getVersion = (packageManager: string, packageName: string, fallback = '', ref = 'latest') =>
|
||||
new Promise<string>(async (resolve) => {
|
||||
let registry = await getRegistry(packageManager);
|
||||
const { version } = await fetch(`${registry}/${packageName}/latest`, {
|
||||
const { version } = await fetch(`${registry}/${packageName}/${ref}`, {
|
||||
redirect: 'follow',
|
||||
})
|
||||
.then((res) => res.json())
|
||||
|
|
Loading…
Add table
Reference in a new issue