Skip to content

Commit

Permalink
fix: documented dev features in readme.
Browse files Browse the repository at this point in the history
Also found and fixed bug in --dry-run while testing docs.

Closes #54
  • Loading branch information
tgetgood authored and RichardLitt committed Dec 11, 2017
1 parent 5a63c6c commit fb27a8d
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
16 changes: 16 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,22 @@ Type: `string`

Only traverse the given repository.

## Development

There are several extra flags that are useful for development and diagnosing
issues:

`-v, --verbose` prints out each query that is sent to the api along with its
cost and the quota remaining after it is run.

`--debug` prints out each query sent to the server and the raw response. This is
extremely verbose.

`--dry-run` prints the cost of the first query that would have been run *without
running it*. Note that since the query isn't executed, follow up queries aren't
possible. when used with the `-c, --config` option, dry runs the first query for
each entry of the config file.

## License

MIT © [Richard Littauer](http://burntfen.com)
8 changes: 4 additions & 4 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ const toCSV = json => {
writer.stringifyRecords(flatten(json))
}

const verifyResultHasKey = (key, query) =>
const verifyResultHasKey = (key, query, dryRun) =>
x => {
if (x[key] == null) {
if (!dryRun && x[key] == null) {
throw new Error(`Bad query: ${key} '${query}' does not exist`)
} else {
return x
Expand Down Expand Up @@ -89,7 +89,7 @@ const repoContributors =
verbose,
name: `repoContributors: ${user}/${repo}`,
query: queries.repository(repo, user, before, after)
}).then(verifyResultHasKey('repository', user + '/' + repo))
}).then(verifyResultHasKey('repository', user + '/' + repo, dryRun))
.then(json => {
if (dryRun) {
return json
Expand All @@ -112,7 +112,7 @@ const orgContributors = ({token, orgName, before, after, debug, dryRun, verbose}
verbose,
name: `orgContributors: ${orgName}`,
query: queries.orgRepos(orgName, before, after)
}).then(verifyResultHasKey('organization', orgName))
}).then(verifyResultHasKey('organization', orgName, dryRun))
.then(data => {
if (dryRun) {
return data
Expand Down

0 comments on commit fb27a8d

Please sign in to comment.