octokit-auth-netrc
Advanced tools
Comparing version 1.0.0-alpha.1 to 1.0.0-alpha.2
@@ -6,3 +6,3 @@ // #### Import | ||
// remark-usage-ignore-next | ||
// remark-usage-ignore-next 6 | ||
stubbedFs({ | ||
@@ -9,0 +9,0 @@ [`${process.env.HOME}/.netrc`]: ` |
@@ -13,3 +13,7 @@ 'use strict'; | ||
return authToken.createTokenAuth(githubCredentials.login); | ||
if (githubCredentials) return authToken.createTokenAuth(githubCredentials.login); | ||
const error = new Error('No entry was found for `api.github.com` in your `~/.netrc` file'); | ||
error.code = 'ENONETRCTOKEN'; | ||
throw error; | ||
} | ||
@@ -16,0 +20,0 @@ |
@@ -7,3 +7,7 @@ import { createTokenAuth } from '@octokit/auth-token'; | ||
return createTokenAuth(githubCredentials.login); | ||
if (githubCredentials) return createTokenAuth(githubCredentials.login); | ||
const error = new Error('No entry was found for `api.github.com` in your `~/.netrc` file'); | ||
error.code = 'ENONETRCTOKEN'; | ||
throw error; | ||
} | ||
@@ -10,0 +14,0 @@ |
@@ -5,3 +5,3 @@ { | ||
"license": "MIT", | ||
"version": "1.0.0-alpha.1", | ||
"version": "1.0.0-alpha.2", | ||
"files": [ | ||
@@ -8,0 +8,0 @@ "example.js", |
@@ -16,2 +16,3 @@ # octokit-auth-netrc | ||
* [Installation](#installation) | ||
* [Defining your token](#defining-your-token) | ||
* [Example](#example) | ||
@@ -44,2 +45,10 @@ * [Import](#import) | ||
### Defining your token | ||
Add a [personal access token](https://help.github.com/en/articles/creating-a-personal-access-token-for-the-command-line) | ||
to your [`~/.netrc` file](https://ec.haxx.se/usingcurl-netrc.html) | ||
machine api.github.com | ||
login <personal access token here> | ||
### Example | ||
@@ -53,10 +62,2 @@ | ||
```javascript | ||
[`${process.env.HOME}/.netrc`]: ` | ||
machine api.github.com | ||
login asdflkajsdflkjadlfjalsdkfjalsdfja | ||
` | ||
}); | ||
``` | ||
#### Authenticate | ||
@@ -76,3 +77,5 @@ | ||
returns an object with an [`auth()` method](#auth) | ||
Returns an [`auth()` function](#auth) after reading your token from the | ||
`~/.netrc` file. Throws an error with code `ENONETRCTOKEN` when an entry for | ||
`api.github.com` is not found in the `~/.netrc` file. | ||
@@ -82,5 +85,5 @@ #### `auth()` | ||
The `auth()` method has no options. It returns a promise which resolves with | ||
the authentication object. | ||
the [authentication object](#authentication-object). | ||
#### Authentication object | ||
##### Authentication object | ||
@@ -87,0 +90,0 @@ <table width="100%"> |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
14147
41
189