From 6b79f189431d515a414aecc26dbea48ef85c2e9d Mon Sep 17 00:00:00 2001 From: Buster Collings Date: Mon, 27 Aug 2018 15:09:15 -0500 Subject: [PATCH 1/4] Allow `process.env.GITHUB_TOKEN` for auth It works as expected with github-base and makes testing forks locally easier. --- test/support/auth.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/test/support/auth.js b/test/support/auth.js index 64658e4..3f19113 100644 --- a/test/support/auth.js +++ b/test/support/auth.js @@ -14,6 +14,9 @@ if (!auth) { } else { auth.username = argv.username || argv._[0] || process.env.GITHUB_USERNAME; auth.password = argv.password || argv._[1] || process.env.GITHUB_PASSWORD; + if (!auth.username || !auth.password) { + auth.token = process.env.GITHUB_TOKEN; + } } } From fc410cd8ebd1f4627da590a26bb14d0dc9715b61 Mon Sep 17 00:00:00 2001 From: Buster Collings Date: Mon, 27 Aug 2018 15:11:18 -0500 Subject: [PATCH 2/4] Make `dest` optional When it's not provided just console.log the result. --- bin/cli.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/bin/cli.js b/bin/cli.js index d0cb4c9..35c81d8 100644 --- a/bin/cli.js +++ b/bin/cli.js @@ -6,7 +6,10 @@ const write = require('write'); repos(argv._[0].split(','), argv) .then(res => { - let filepath = argv._[1] || 'repos.json'; + let filepath = argv._[1]; + if (!filepath) { + return console.log(JSON.stringify(res, null, 2)); + } write(filepath, JSON.stringify(res, null, 2), err => { if (err) { console.error(err); From efa2e12f3cb9a5fb48e310e1acc266aa53018a03 Mon Sep 17 00:00:00 2001 From: Buster Collings Date: Mon, 27 Aug 2018 15:12:03 -0500 Subject: [PATCH 3/4] Update CLI reference for `dest` Explain that it's now an optional argument. --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index c9b572e..3ae5af7 100644 --- a/README.md +++ b/README.md @@ -55,11 +55,11 @@ See the [GitHub API documentation for repositories](https://developer.github.com ## CLI ```sh -$ repos +$ repos [dest] ``` * `names` - one or more comma-separated user names or orgs -* `dest` - destination path to use, default is `repos.json` +* `dest` - destination path for JSON file (optional) ## About From bd0b2dad3a240fd762cd916bd1d8ae5f993a89f8 Mon Sep 17 00:00:00 2001 From: Buster Collings Date: Mon, 27 Aug 2018 17:01:14 -0500 Subject: [PATCH 4/4] Attempt to use `process.env.GITHUB_TOKEN` Use when other when other arguments aren't provided. --- bin/cli.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/bin/cli.js b/bin/cli.js index 35c81d8..851fa04 100644 --- a/bin/cli.js +++ b/bin/cli.js @@ -4,6 +4,10 @@ const repos = require('../'); const argv = require('minimist')(process.argv.slice(2)); const write = require('write'); +if (!argv.token && !(argv.username && argv.password)) { + argv.token = process.env.GITHUB_TOKEN; +} + repos(argv._[0].split(','), argv) .then(res => { let filepath = argv._[1];