If a user places a token in ~/.github-labels themselves, it's very likely there'll be a \n at the end when read into node as a string. With that \n, GitHub errors with Bad credentials.
This PR removes a trailing newline if it's there, then tests the token before moving on. If the token fails, more verbose errors are output.
In general, I think it's a good idea to always output the error message that GitHub returns so users are informed.
When the token is read from the dotfile, sometimes it will have
a newline at the end with which GitHub errors: Bad credentials.
This does a string replace to remove newlines.
Test the token when being read from the dotfile before deciding
everything is ok. Error if authentication fails.
Show GitHub error message when failing so the user understands
what's going wrong.
If a user places a token in
~/.github-labels
themselves, it's very likely there'll be a\n
at the end when read into node as a string. With that\n
, GitHub errors withBad credentials
.This PR removes a trailing newline if it's there, then tests the token before moving on. If the token fails, more verbose errors are output.
In general, I think it's a good idea to always output the error message that GitHub returns so users are informed.
Commit message: