Skip to content

Commit

Permalink
handle case where there is no github repo
Browse files Browse the repository at this point in the history
  • Loading branch information
fiennyangeln committed Sep 25, 2018
1 parent c0cc79f commit a76a887
Showing 1 changed file with 20 additions and 17 deletions.
37 changes: 20 additions & 17 deletions v2/lib/load/docs/metadata.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,24 +68,27 @@ module.exports = async function processMetadata(
| grep -I "^author " | sort | uniq -c | sort -nr; \
`
).toString().split('\n');
let authorData;
const authors = [];
let totalLineCount = 0;
results.forEach(result => {
if ((authorData = authorRegex.exec(result)) !== null) {
const lineCount = parseInt(authorData[1]);
const name = authorData[2];
authors.push({
lineCount,
name,
});
totalLineCount += lineCount;
}
authorRegex.lastIndex = 0;
});
/* handle case where it's not github repo */
if (results.length && results[0].length) {
let authorData;
const authors = [];
let totalLineCount = 0;
results.forEach(result => {
if ((authorData = authorRegex.exec(result)) !== null) {
const lineCount = parseInt(authorData[1]);
const name = authorData[2];
authors.push({
lineCount,
name,
});
totalLineCount += lineCount;
}
authorRegex.lastIndex = 0;
});

metadata.authors = authors;
metadata.totalLineCount = totalLineCount;
metadata.authors = authors;
metadata.totalLineCount = totalLineCount;
}

/* language */
const language = getLanguage(filepath, refDir, env);
Expand Down

0 comments on commit a76a887

Please sign in to comment.