Skip to content

Commit

Permalink
Fixed order of operations for parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
davglass committed Sep 7, 2016
1 parent 9d4db11 commit 60fce1a
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions lib/index.js
Expand Up @@ -112,20 +112,27 @@ var flatten = function(options) {
moduleInfo.licenses = licenseData.map(function(license){
/*istanbul ignore else*/
if (typeof license === 'object') {
return license.type;
return license.type || license.name;
} else if (typeof license === 'string') {
return license;
}
});
} else if (typeof licenseData === 'object' && licenseData.type) {
moduleInfo.licenses = licenseData.type;
} else if (typeof licenseData === 'object' && (licenseData.type || licenseData.name)) {
moduleInfo.licenses = licenseData.type || licenseData.name;
} else if (typeof licenseData === 'string') {
moduleInfo.licenses = licenseData;
}
} else if (license(json.readme)) {
moduleInfo.licenses = license(json.readme);
}

if (Array.isArray(moduleInfo.licenses)) {
/*istanbul ignore else*/
if (moduleInfo.licenses.length === 1) {
moduleInfo.licenses = moduleInfo.licenses[0];
}
}

/*istanbul ignore else*/
if (json.path && fs.existsSync(json.path)) {
files = fs.readdirSync(json.path).filter(function(filename) {
Expand All @@ -147,13 +154,6 @@ var flatten = function(options) {
}
});

if (Array.isArray(moduleInfo.licenses)) {
/*istanbul ignore else*/
if (moduleInfo.licenses.length === 1) {
moduleInfo.licenses = moduleInfo.licenses[0];
}
}

/*istanbul ignore else*/
if (json.dependencies) {
Object.keys(json.dependencies).forEach(function(name) {
Expand Down

0 comments on commit 60fce1a

Please sign in to comment.