Skip to content

Commit

Permalink
parse tag from command
Browse files Browse the repository at this point in the history
  • Loading branch information
apatel369 committed Nov 30, 2024
1 parent 4bde0d0 commit cfd35f5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
6 changes: 4 additions & 2 deletions packages/create-astro/src/actions/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ export interface Context {
}

export async function getContext(argv: string[]): Promise<Context> {
const packageTag = argv.find((argItem) => /^(astro|create-astro)@/.exec(argItem))?.split('@')[1];

const flags = arg(
{
'--template': String,
Expand Down Expand Up @@ -76,7 +78,7 @@ export async function getContext(argv: string[]): Promise<Context> {
} = flags;
let projectName = cwd;
const tag = ref === 'next' ? 'beta' : ref;

if (no) {
yes = false;
if (install == undefined) install = false;
Expand All @@ -94,7 +96,7 @@ export async function getContext(argv: string[]): Promise<Context> {
prompt,
packageManager,
username: getName(),
version: getVersion(packageManager, 'astro', process.env.ASTRO_VERSION, tag),
version: getVersion(packageManager, 'astro', packageTag, process.env.ASTRO_VERSION),
skipHouston,
fancy,
add,
Expand Down
4 changes: 2 additions & 2 deletions packages/create-astro/src/messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,10 @@ export const getName = () =>
});
});

export const getVersion = (packageManager: string, packageName: string, fallback = '', tag = 'latest') =>
export const getVersion = (packageManager: string, packageName: string, packageTag = 'latest', fallback = '') =>
new Promise<string>(async (resolve) => {
let registry = await getRegistry(packageManager);
const { version } = await fetch(`${registry}/${packageName}/${tag}`, {
const { version } = await fetch(`${registry}/${packageName}/${packageTag}`, {
redirect: 'follow',
})
.then((res) => res.json())
Expand Down

0 comments on commit cfd35f5

Please sign in to comment.