Skip to content

Commit

Permalink
Handle error state for version (#7939)
Browse files Browse the repository at this point in the history
* fix(create-astro): handle error state for version

* fix: handle missing version
  • Loading branch information
natemoo-re authored Aug 3, 2023
1 parent a2b989c commit 89cd4b8
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .changeset/late-falcons-dream.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'create-astro': patch
---

Handle error state for version number
2 changes: 1 addition & 1 deletion packages/create-astro/src/actions/intro.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
7 changes: 4 additions & 3 deletions packages/create-astro/src/messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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) => {
Expand Down

0 comments on commit 89cd4b8

Please sign in to comment.