Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,11 @@ See the [GitHub API documentation for repositories](https://developer.github.com
## CLI

```sh
$ repos <names> <dest>
$ repos <names> [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

Expand Down
9 changes: 8 additions & 1 deletion bin/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,16 @@ 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] || '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);
Expand Down
3 changes: 3 additions & 0 deletions test/support/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
}

Expand Down