Skip to content

Commit 20d7f12

Browse files
authored
Merge pull request #9 from cheton/feature/baseurl
Adds supports for specifying an API endpoint other than https://api.github.com
2 parents baa99d9 + ef2810e commit 20d7f12

2 files changed

Lines changed: 8 additions & 10 deletions

File tree

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,11 @@
2929
"cli"
3030
],
3131
"dependencies": {
32-
"@octokit/rest": "^16.9.0",
32+
"@octokit/rest": "^16.23.2",
3333
"babel-runtime": "^6.26.0",
34-
"commander": "^2.19.0",
34+
"commander": "^2.20.0",
3535
"http-link-header": "^1.0.2",
36-
"mime-types": "^2.1.21",
36+
"mime-types": "^2.1.22",
3737
"minimatch": "^3.0.4",
3838
"url-parse": "^1.4.4"
3939
},
@@ -42,6 +42,6 @@
4242
"babel-plugin-transform-runtime": "^6.23.0",
4343
"babel-preset-env": "^1.7.0",
4444
"babel-preset-stage-0": "^6.24.1",
45-
"tap": "^12.1.1"
45+
"tap": "^12.6.1"
4646
}
4747
}

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)