Handle error state for version (#7939)
* fix(create-astro): handle error state for version * fix: handle missing version
This commit is contained in:
parent
a2b989cba1
commit
89cd4b877e
3 changed files with 10 additions and 4 deletions
5
.changeset/late-falcons-dream.md
Normal file
5
.changeset/late-falcons-dream.md
Normal file
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
'create-astro': patch
|
||||
---
|
||||
|
||||
Handle error state for version number
|
|
@ -11,7 +11,7 @@ export async function intro(ctx: Pick<Context, 'skipHouston' | 'version' | 'user
|
|||
'Welcome',
|
||||
'to',
|
||||
label('astro', color.bgGreen, color.black),
|
||||
color.green(`v${ctx.version}`) + ',',
|
||||
(ctx.version ? color.green(`v${ctx.version}`) : '') + ',',
|
||||
`${ctx.username}!`,
|
||||
],
|
||||
random(welcome),
|
||||
|
|
|
@ -83,7 +83,8 @@ export const getVersion = () =>
|
|||
if (v) return resolve(v);
|
||||
let registry = await getRegistry();
|
||||
const { version } = await fetch(`${registry}/astro/latest`, { redirect: 'follow' }).then(
|
||||
(res) => res.json()
|
||||
(res) => res.json(),
|
||||
() => ({ version: '' })
|
||||
);
|
||||
v = version;
|
||||
resolve(version);
|
||||
|
@ -92,9 +93,9 @@ export const getVersion = () =>
|
|||
export const log = (message: string) => stdout.write(message + '\n');
|
||||
export const banner = async (version: string) =>
|
||||
log(
|
||||
`\n${label('astro', color.bgGreen, color.black)} ${color.green(
|
||||
`\n${label('astro', color.bgGreen, color.black)} ${version ? color.green(
|
||||
color.bold(`v${version}`)
|
||||
)} ${color.bold('Launch sequence initiated.')}`
|
||||
): ''} ${color.bold('Launch sequence initiated.')}`
|
||||
);
|
||||
|
||||
export const info = async (prefix: string, text: string) => {
|
||||
|
|
Loading…
Reference in a new issue