octokit-auth-netrc
Advanced tools
Comparing version 2.0.1 to 2.1.0
@@ -12,8 +12,8 @@ 'use strict'; | ||
function netrcAuth () { | ||
const githubCredentials = netrc__default["default"]()['api.github.com']; | ||
function netrcAuth ({domain = 'api.github.com'} = {}) { | ||
const githubCredentials = netrc__default["default"]()[domain]; | ||
if (githubCredentials) return authToken.createTokenAuth(githubCredentials.login); | ||
const error = new Error('No entry was found for `api.github.com` in your `~/.netrc` file'); | ||
const error = new Error(`No entry was found for \`${domain}\` in your \`~/.netrc\` file`); | ||
error.code = 'ENONETRCTOKEN'; | ||
@@ -20,0 +20,0 @@ throw error; |
import { createTokenAuth } from '@octokit/auth-token'; | ||
import netrc from 'netrc'; | ||
function netrcAuth () { | ||
const githubCredentials = netrc()['api.github.com']; | ||
function netrcAuth ({domain = 'api.github.com'} = {}) { | ||
const githubCredentials = netrc()[domain]; | ||
if (githubCredentials) return createTokenAuth(githubCredentials.login); | ||
const error = new Error('No entry was found for `api.github.com` in your `~/.netrc` file'); | ||
const error = new Error(`No entry was found for \`${domain}\` in your \`~/.netrc\` file`); | ||
error.code = 'ENONETRCTOKEN'; | ||
@@ -11,0 +11,0 @@ throw error; |
@@ -5,13 +5,10 @@ { | ||
"license": "MIT", | ||
"version": "2.0.1", | ||
"version": "2.1.0", | ||
"engines": { | ||
"node": "^14.15 || >=16" | ||
}, | ||
"files": [ | ||
"example.js", | ||
"lib/" | ||
], | ||
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"author": "Matt Travi <npm@travi.org> (https://matt.travi.org/)", | ||
"repository": "travi/octokit-auth-netrc", | ||
"bugs": "https://github.com/travi/octokit-auth-netrc/issues", | ||
"homepage": "https://npm.im/octokit-auth-netrc", | ||
"runkitExampleFilename": "./example.js", | ||
@@ -21,6 +18,2 @@ "main": "lib/index.cjs.js", | ||
"sideEffects": false, | ||
"repository": "travi/octokit-auth-netrc", | ||
"bugs": "https://github.com/travi/octokit-auth-netrc/issues", | ||
"homepage": "https://npm.im/octokit-auth-netrc", | ||
"author": "Matt Travi <npm@travi.org> (https://matt.travi.org/)", | ||
"scripts": { | ||
@@ -53,15 +46,26 @@ "test": "npm-run-all --print-label build --parallel lint:* --parallel test:*", | ||
}, | ||
"files": [ | ||
"example.js", | ||
"lib/" | ||
], | ||
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"dependencies": { | ||
"@octokit/auth-token": "^3.0.0", | ||
"netrc": "0.1.4" | ||
}, | ||
"devDependencies": { | ||
"@babel/register": "7.18.6", | ||
"@cucumber/cucumber": "8.4.0", | ||
"@octokit/core": "4.0.2", | ||
"@travi/any": "2.1.5", | ||
"@travi/babel-preset": "3.0.89", | ||
"@travi/eslint-config": "3.0.4", | ||
"@babel/register": "7.18.9", | ||
"@cucumber/cucumber": "8.10.0", | ||
"@octokit/core": "4.1.0", | ||
"@travi/any": "2.1.6", | ||
"@travi/babel-preset": "3.0.96", | ||
"@travi/eslint-config": "3.0.19", | ||
"@travi/eslint-config-cucumber": "1.0.6", | ||
"@travi/eslint-config-mocha": "1.0.18", | ||
"@travi/eslint-config-mocha": "1.0.19", | ||
"ban-sensitive-files": "1.9.18", | ||
"c8": "7.11.3", | ||
"chai": "4.3.6", | ||
"commitlint-config-travi": "1.4.16", | ||
"c8": "7.12.0", | ||
"chai": "4.3.7", | ||
"commitlint-config-travi": "1.4.23", | ||
"cross-env": "7.0.3", | ||
@@ -72,23 +76,19 @@ "cz-conventional-changelog": "3.3.0", | ||
"http-status-codes": "2.2.0", | ||
"husky": "8.0.1", | ||
"lockfile-lint": "4.7.6", | ||
"ls-engines": "0.7.0", | ||
"mocha": "10.0.0", | ||
"mock-fs": "5.1.2", | ||
"nock": "13.2.8", | ||
"husky": "8.0.3", | ||
"lockfile-lint": "4.10.0", | ||
"ls-engines": "0.8.0", | ||
"mocha": "10.2.0", | ||
"mock-fs": "5.2.0", | ||
"nock": "13.3.0", | ||
"npm-run-all": "4.1.5", | ||
"package-preview": "4.0.0", | ||
"remark-cli": "11.0.0", | ||
"remark-preset-lint-travi": "4.0.1", | ||
"remark-preset-lint-travi": "4.0.2", | ||
"remark-toc": "8.0.1", | ||
"remark-usage": "10.0.1", | ||
"rimraf": "3.0.2", | ||
"rollup": "2.75.7", | ||
"rimraf": "4.0.4", | ||
"rollup": "2.79.1", | ||
"rollup-plugin-auto-external": "2.0.0", | ||
"sinon": "14.0.0" | ||
}, | ||
"dependencies": { | ||
"@octokit/auth-token": "^3.0.0", | ||
"netrc": "0.1.4" | ||
"sinon": "15.0.1" | ||
} | ||
} |
@@ -52,2 +52,6 @@ # octokit-auth-netrc | ||
machine github.acme-inc.com | ||
login <personal access token here> | ||
### Example | ||
@@ -64,3 +68,3 @@ | ||
```javascript | ||
const auth = createNetrcAuth(); | ||
const auth = createNetrcAuth(); // defaults to api.github.com | ||
@@ -70,2 +74,9 @@ (async () => { | ||
})(); | ||
// For use with GHES, override the default domain | ||
const auth = createNetrcAuth({ domain: 'github.acme-inc.com' }); | ||
(async () => { | ||
await auth(); | ||
})(); | ||
``` | ||
@@ -72,0 +83,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
14898
156