Skip to content

Commit

Permalink
Fixes #76 - If readme data not found, look for it on disk
Browse files Browse the repository at this point in the history
  • Loading branch information
davglass committed Sep 6, 2016
1 parent d7dc3c1 commit d783029
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ var flatten = function(options) {
key = json.name + '@' + json.version,
colorize = options.color,
unknown = options.unknown,
readmeFile,
licenseData, files = [], licenseFile;

/*istanbul ignore next*/
Expand Down Expand Up @@ -97,6 +98,14 @@ var flatten = function(options) {
}

licenseData = json.license || json.licenses || undefined;

if (json.path && (!json.readme || json.readme.toLowerCase().indexOf('no readme data found') > -1)) {
readmeFile = path.join(json.path, 'README.md');
if (fs.existsSync(readmeFile)) {
json.readme = fs.readFileSync(readmeFile, 'utf8').toString();
}
}

if (licenseData) {
/*istanbul ignore else*/
if (Array.isArray(licenseData) && licenseData.length > 0) {
Expand Down

0 comments on commit d783029

Please sign in to comment.