Skip to content

Commit ef2810e

Browse files
committed
Add a baseurl option that allows you to specify an API endpoint
1 parent 8763706 commit ef2810e

1 file changed

Lines changed: 4 additions & 6 deletions

File tree

src/index.js

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import pkg from '../package.json';
1313
program
1414
.version(pkg.version)
1515
.usage('<command> [<args>]')
16+
.option('--baseurl <baseurl>', 'API endpoint', 'https://api.github.com')
1617
.option('-T, --token <token>', 'OAuth2 token')
1718
.option('-o, --owner <owner>', 'owner')
1819
.option('-r, --repo <repo>', 'repo')
@@ -36,13 +37,10 @@ program.parse(process.argv);
3637

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

40+
const token = (program.token || process.env.GITHUB_TOKEN);
3941
const octokit = new Octokit({
40-
auth() {
41-
const token = (program.token || process.env.GITHUB_TOKEN);
42-
if (token) {
43-
return `token ${token}`;
44-
}
45-
}
42+
auth: token || null,
43+
baseUrl: program.baseurl,
4644
});
4745

4846
function next(response) {

0 commit comments

Comments
 (0)