Skip to content

Commit

Permalink
Merge pull request #9 from cheton/feature/baseurl
Browse files Browse the repository at this point in the history
Adds supports for specifying an API endpoint other than https://api.github.com
  • Loading branch information
cheton committed Apr 4, 2019
2 parents baa99d9 + ef2810e commit 20d7f12
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@
"cli"
],
"dependencies": {
"@octokit/rest": "^16.9.0",
"@octokit/rest": "^16.23.2",
"babel-runtime": "^6.26.0",
"commander": "^2.19.0",
"commander": "^2.20.0",
"http-link-header": "^1.0.2",
"mime-types": "^2.1.21",
"mime-types": "^2.1.22",
"minimatch": "^3.0.4",
"url-parse": "^1.4.4"
},
Expand All @@ -42,6 +42,6 @@
"babel-plugin-transform-runtime": "^6.23.0",
"babel-preset-env": "^1.7.0",
"babel-preset-stage-0": "^6.24.1",
"tap": "^12.1.1"
"tap": "^12.6.1"
}
}
10 changes: 4 additions & 6 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import pkg from '../package.json';
program
.version(pkg.version)
.usage('<command> [<args>]')
.option('--baseurl <baseurl>', 'API endpoint', 'https://api.github.com')
.option('-T, --token <token>', 'OAuth2 token')
.option('-o, --owner <owner>', 'owner')
.option('-r, --repo <repo>', 'repo')
Expand All @@ -36,13 +37,10 @@ program.parse(process.argv);

const [command, ...args] = program.args;

const token = (program.token || process.env.GITHUB_TOKEN);
const octokit = new Octokit({
auth() {
const token = (program.token || process.env.GITHUB_TOKEN);
if (token) {
return `token ${token}`;
}
}
auth: token || null,
baseUrl: program.baseurl,
});

function next(response) {
Expand Down

0 comments on commit 20d7f12

Please sign in to comment.