Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@ module.exports = function checkPath (packageName, basePath, overrides, includeDe
}
}

var licensesRaw = []
var license = 'unknown'
var licenseFilePath

Expand All @@ -242,15 +243,17 @@ module.exports = function checkPath (packageName, basePath, overrides, includeDe
} else if (packageJson.license) {
licenses.push(packageJson.license)
}
license = licenses.map(getJsonLicense).map(formatLicense).join(', ')
licensesRaw = licenses.map(getJsonLicense)
license = licensesRaw.map(formatLicense).join(', ')
} else {
// Look for file with "license" or "copying" in its name
var files = fs.readdirSync(basePath)
files.some(function (name) {
if (/licen[sc]e/i.test(name) || /copying.*/i.test(name)) {
var file = path.join(basePath, name)
if (fs.statSync(file).isFile()) {
license = formatLicense(getFileLicense(file))
licensesRaw = [getFileLicense(file)]
license = formatLicense(licensesRaw[0])
licenseFilePath = file
return true
}
Expand All @@ -265,6 +268,7 @@ module.exports = function checkPath (packageName, basePath, overrides, includeDe
if (fs.statSync(file).isFile()) {
var result = getReadmeLicense(file)
if (result) {
licensesRaw = [result]
license = formatLicense(result)
licenseFilePath = file
return license !== 'nomatch'
Expand Down Expand Up @@ -303,6 +307,7 @@ module.exports = function checkPath (packageName, basePath, overrides, includeDe
name: packageJson.name,
version: packageJson.version,
license: license,
licensesRaw: licensesRaw,
licenseFile: licenseFilePath && path.relative(process.cwd(), licenseFilePath),
deps: dependencies.sort(function (dep1, dep2) { return dep1.name.localeCompare(dep2.name) })
}
Expand Down
1 change: 1 addition & 0 deletions test/licensecheck.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ suite('licensecheck')

function replacer (key, value) {
switch (key) {
case 'licensesRaw':
case 'licenseFile':
case 'version':
return undefined
Expand Down