popomore/github-labels — pull request #1 by henrahmagix (2014-05-26 16:39:47+00:00)
Title: Token in dotfile breaks this without info when it has a newline at EOF

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.

```bash
$: echo 'bad-token' > ~/.github-labels
$: labels -c ~/.config/github-labels/labels-api.json henrahmagix/labels-test
>> Authorizing
>> Token error
{"message":"Bad credentials","documentation_url":"https://developer.github.com/v3"}
```

---

Commit message:
>## Fix malformed token when \n is at the end.
>
* 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.