Skip to content
This repository has been archived by the owner on Apr 6, 2023. It is now read-only.

fix(nuxi): show an error if no value is supplied for the --template flag #9946

Merged
merged 2 commits into from
Jan 4, 2023

Conversation

jamesgeorge007
Copy link
Contributor

@jamesgeorge007 jamesgeorge007 commented Jan 4, 2023

πŸ”— Linked issue

nuxt/nuxt#12608

❓ Type of change

  • [ ] πŸ“– Documentation (updates to the documentation or readme)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • [ ] πŸ‘Œ Enhancement (improving an existing functionality like performance)
  • [ ] ✨ New feature (a non-breaking change that adds functionality)
  • [ ] ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

πŸ“š Description

Previously not supplying a value with the --template flag results in the following error.

image

This PR aims at showing an error message and exiting with a code of 1 in this scenario.

Screenshot 2023-01-04 at 11 18 36 PM

πŸ“ Checklist

  • I have linked an issue or discussion.
  • [ ] I have updated the documentation accordingly.

@codesandbox
Copy link

codesandbox bot commented Jan 4, 2023

CodeSandbox logoCodeSandbox logoΒ  Open in CodeSandbox Web Editor | VS Code | VS Code Insiders

@pi0 pi0 merged commit da38c62 into nuxt:main Jan 4, 2023
@pi0
Copy link
Member

pi0 commented Jan 4, 2023

Thanks

@jamesgeorge007 jamesgeorge007 deleted the hotfix/nuxi-init branch January 4, 2023 18:23
@jamesgeorge007
Copy link
Contributor Author

jamesgeorge007 commented Jan 4, 2023

@pi0, I noticed that a failed attempt to download the template results in the stack trace being logged in to the console. May I know if it's intentional? Else, we could wrap it within a try-catch block.

const t = await downloadTemplate(template, {
dir: args._[0] as string,
force: args.force,
offline: args.offline,
preferOffline: args['prefer-offline'],
registry: process.env.NUXI_INIT_REGISTRY || DEFAULT_REGISTRY
})

@pi0
Copy link
Member

pi0 commented Jan 4, 2023

That would be an excellent DX enhancement indeed.

We can give a more precise message from unjs/giget as well (if download fails without local cache, etc), and in nuxi cli, use error.toString() with it's custom implementation from giget (this way unexpected errors preserve their stack)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants