Skip to content

Commit e1078fe

Browse files
committed
allow anonymous for tests
1 parent cae95e0 commit e1078fe

2 files changed

Lines changed: 8 additions & 5 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"prepublish": "npm run build",
1212
"build": "babel --out-dir ./lib ./src",
1313
"_test": "tap test/*.js --no-timeout --node-arg=--require --node-arg=babel-register --node-arg=--require --node-arg=babel-polyfill",
14-
"test": "npm run build && node lib/index.js --owner cheton --repo github-release-cli list"
14+
"test": "npm run build && node lib/index.js -a --owner cheton --repo github-release-cli list"
1515
},
1616
"files": [
1717
"bin",

src/index.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ program
2222
.option('-t, --tag <tag>', 'tag')
2323
.option('-n, --name <name>', 'name')
2424
.option('-b, --body <body>', 'body', false)
25+
.option('-a, --anonymous', 'Use github API without token mainly for testing', false)
2526
.option('-d, --draft [value]', 'draft', function(val) {
2627
if (String(val).toLowerCase() === 'false') {
2728
return false;
@@ -39,10 +40,12 @@ program.parse(process.argv);
3940

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

42-
octokit.authenticate({
43-
type: 'oauth',
44-
token: program.token || process.env.GITHUB_TOKEN
45-
});
43+
if (!program.anonymous) {
44+
octokit.authenticate({
45+
type: 'oauth',
46+
token: program.token || process.env.GITHUB_TOKEN
47+
});
48+
}
4649

4750
function next(response) {
4851
if (!response.headers || !response.headers.link) return false;

0 commit comments

Comments
 (0)