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

CLI: better existence check #2700

Merged
merged 3 commits into from
Feb 25, 2018
Merged

Conversation

chabou
Copy link
Collaborator

@chabou chabou commented Feb 23, 2018

NPM registry is broken for some (unpublished?) package:
https://registry.npmjs.org/hyper-cwd
https://api.npms.io/v2/package/hyper-cwd (error 500)

Checking headers on npm is not enough.

Now, versions key existence is checked in content

cli/api.js Outdated
.get(registryUrl + name.toLowerCase(), {timeout: 10000, json: true})
.then(res => {
if (!res.body.versions) {
throw new Error();
Copy link
Contributor

Choose a reason for hiding this comment

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

Error should be defined with a message.

Copy link
Contributor

Choose a reason for hiding this comment

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

Meh, just used to get into the .catch block here. Could alternatively return Promise.reject();.

Copy link
Contributor

Choose a reason for hiding this comment

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

Your ready to go. 🚀

@chabou
Copy link
Collaborator Author

chabou commented Feb 23, 2018

@brandon93s @ppot Thank you for your reviews. You were both right. I refactored it and looks a way better now.
Bonus: There is a convenient message for errors.

@chabou chabou merged commit e17aab6 into vercel:canary Feb 25, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants