Skip to content

Commit

Permalink
fix(debugging): removed auto verbosity
Browse files Browse the repository at this point in the history
It was breaking stdout compatibility. Now only output correct json
unless -v or --debug are specified.
  • Loading branch information
tgetgood committed Nov 2, 2017
1 parent b59a656 commit c104c50
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
6 changes: 3 additions & 3 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const parseGitURL = url => {

const getCurrentRepoInfo = () => shellOut(gitConfigCommand)
.then(parseGitURL)
.then(x => {return {user: x[1], repo: x[2]}})
.then(x => { return {user: x[1], repo: x[2]} })

//
// CSV Output
Expand Down Expand Up @@ -80,7 +80,7 @@ const repoContributors = (
if (dryRun) {
return json
} else {
return queries.cleanRepo(token, json.repository, before, after)
return queries.cleanRepo(token, json.repository, before, after, verbose)
}
})

Expand All @@ -102,7 +102,7 @@ const orgContributors = ({token, orgName, before, after, debug, dryRun, verbose}
if (dryRun) {
return data
} else {
return queries.cleanOrgRepos(token, data, before, after)
return queries.cleanOrgRepos(token, data, before, after, verbose)
}
})

Expand Down
13 changes: 10 additions & 3 deletions src/queries.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,10 @@ const continuationQuery = (id, parentType, childType, cursor, n, query) =>
// Data Filtering (co-queries if you will)
/// //

// Yay globals. For one off script purposes this is fine, but if we're
// interleaving async calls to the main functions this will go awry.
let verboseCont = false

/** Recursive fetcher keeps grabbing the next page from the API until there are
* none left. Returns the aggregate result of all fetches.
*/
Expand All @@ -136,7 +140,7 @@ const fetchAll = async ({token, acc, data, type, key, count, query, name}) => {
const next = await graphql.executequery({
token,
name,
verbose: true,
verbose: verboseCont,
query: continuationQuery(
data.id, type, key, data[key].pageInfo.endCursor, count, query)
})
Expand Down Expand Up @@ -216,7 +220,8 @@ const depaginateAll = async (parent, {token, acc, type, key, query, name}) =>
}))))

/** Parse repository query result and filter for date range. */
const cleanRepo = async (token, result, before, after) => {
const cleanRepo = async (token, result, before, after, verbose) => {
verboseCont = verbose
const tf = timeFilter(before, after)
const process = x => mergeContributions(users(tf(x)))

Expand Down Expand Up @@ -366,7 +371,9 @@ const mergeRepoResults = repos =>
return ret
})

const cleanOrgRepos = async (token, result, before, after) => {
const cleanOrgRepos = async (token, result, before, after, verbose) => {
verboseCont = verbose

const repos = await fetchAll({
token,
name: 'org repos cont',
Expand Down

0 comments on commit c104c50

Please sign in to comment.