-
Notifications
You must be signed in to change notification settings - Fork 22
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
fix: fixing repo related publish errors #46
Conversation
this fixes issues where no error message was printed when a repository was missing or misconfigured. now you get something like ``` npm ERR! code E400 npm ERR! 400 Bad Request - PUT https://.... - npm ERR! =============================== npm ERR! Publish service error npm ERR! ------------------------------- npm ERR! respository https://github.com/<repository> doesnt exist or <user> doesnt have access npm ERR! =============================== npm ERR! npm ERR! A complete log of this run can be found in: npm ERR! /..../.._34_372Z-debug.log ```
src/lib/write-package.ts
Outdated
@@ -122,7 +122,7 @@ export const writePackage = async ( | |||
), | |||
statusCode: 500, | |||
}; | |||
res.end(ret.error); | |||
res.end(JSON.stringify(ret)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here and below - can we use res.json
instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm ok with using res.json.
I like to imagine that using methods only available on http servers makes things easier to move around but in practice no one ever does.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Heh, I come from the other side where I learned express far before the base level HTTP server, so I never know what's express and what's node, like the new jquery vs javascript
src/lib/write-package.ts
Outdated
return ret; | ||
} | ||
|
||
let repoResp = null; | ||
try { | ||
repoResp = await github.getRepo(repo.name, user.token); | ||
} catch (e) { | ||
console.info('failed to get repo response for '+repo.name+' '+e) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thoughts on using backticks and interpolation?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm 🤷♂️
if you don't have new lines in your message back ticks are nearly as easy.
i refactored error handling in write package to usea common function to write and format errors on the resonse. uses res.json, backticks and other suggestions. cc @JustinBeckwith |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
awesome work @soldair, I like that you refactored the response logic. |
this fixes issues where no error message was printed when a repository
was missing or misconfigured. now you get something like
fixes #7