Skip to content

Commit 7d1f69d

Browse files
committed
Use authentication function to return token
1 parent da2502a commit 7d1f69d

1 file changed

Lines changed: 9 additions & 6 deletions

File tree

src/index.js

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,15 @@ program.parse(process.argv);
3636

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

39-
const octoptions = {};
40-
if (command !== 'list') {
41-
octoptions.auth = `token ${program.token || process.env.GITHUB_TOKEN}`
42-
}
43-
const octokit = new Octokit(octoptions);
44-
39+
const octokit = new Octokit({
40+
auth() {
41+
const token = (program.token || process.env.GITHUB_TOKEN);
42+
if (token) {
43+
return `token ${token}`;
44+
}
45+
}
46+
});
47+
4548
function next(response) {
4649
if (!response.headers || !response.headers.link) {
4750
return false;

0 commit comments

Comments
 (0)