mirror of
https://github.com/withastro/astro.git
synced 2025-02-03 22:29:08 -05:00
parse tag from command
This commit is contained in:
parent
4bde0d0d47
commit
cfd35f5e84
2 changed files with 6 additions and 4 deletions
|
@ -34,6 +34,8 @@ export interface Context {
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getContext(argv: string[]): Promise<Context> {
|
export async function getContext(argv: string[]): Promise<Context> {
|
||||||
|
const packageTag = argv.find((argItem) => /^(astro|create-astro)@/.exec(argItem))?.split('@')[1];
|
||||||
|
|
||||||
const flags = arg(
|
const flags = arg(
|
||||||
{
|
{
|
||||||
'--template': String,
|
'--template': String,
|
||||||
|
@ -94,7 +96,7 @@ export async function getContext(argv: string[]): Promise<Context> {
|
||||||
prompt,
|
prompt,
|
||||||
packageManager,
|
packageManager,
|
||||||
username: getName(),
|
username: getName(),
|
||||||
version: getVersion(packageManager, 'astro', process.env.ASTRO_VERSION, tag),
|
version: getVersion(packageManager, 'astro', packageTag, process.env.ASTRO_VERSION),
|
||||||
skipHouston,
|
skipHouston,
|
||||||
fancy,
|
fancy,
|
||||||
add,
|
add,
|
||||||
|
|
|
@ -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) => {
|
new Promise<string>(async (resolve) => {
|
||||||
let registry = await getRegistry(packageManager);
|
let registry = await getRegistry(packageManager);
|
||||||
const { version } = await fetch(`${registry}/${packageName}/${tag}`, {
|
const { version } = await fetch(`${registry}/${packageName}/${packageTag}`, {
|
||||||
redirect: 'follow',
|
redirect: 'follow',
|
||||||
})
|
})
|
||||||
.then((res) => res.json())
|
.then((res) => res.json())
|
||||||
|
|
Loading…
Add table
Reference in a new issue