Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[create-astro] Error on --template that does not exist #6677

Merged
merged 2 commits into from
Mar 28, 2023

Conversation

bholmesdev
Copy link
Contributor

This reverts commit c13d428.

Changes

  • Raise an appropriate error when cloning templates that don't exist. Looks like the giget library only throws when a remote repo does not exist, but will not throw if a specific example inside that repo is missing. This adds an empty dir check, since that's a good chance it didn't work as expected.

Testing

N/A - dry run prevents actually fetching to avoid flakiness

Docs

N/A

@changeset-bot
Copy link

changeset-bot bot commented Mar 27, 2023

🦋 Changeset detected

Latest commit: 5a5c68c

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions github-actions bot added the pkg: create-astro Related to the `create-astro` package (scope) label Mar 27, 2023
@@ -81,11 +86,18 @@ export default async function copyTemplate(tmpl: string, ctx: Context) {
} catch (err: any) {
fs.rmdirSync(ctx.cwd);
if (err.message.includes('404')) {
await error('Error', `Template ${color.reset(tmpl)} ${color.dim('does not exist!')}`);
throw new Error(`Template ${color.reset(tmpl)} ${color.dim('does not exist!')}`);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This used to log the error and close the spinner before ctx.exit could be called. This throws so the higher scope can catch and log appropriately.

@bholmesdev bholmesdev merged commit 4a32620 into main Mar 28, 2023
@bholmesdev bholmesdev deleted the fix/create-astro branch March 28, 2023 11:08
@astrobot-houston astrobot-houston mentioned this pull request Mar 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pkg: create-astro Related to the `create-astro` package (scope)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants