Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to skip validation of license names #27

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
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
4 changes: 2 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
var scan = require('./scan')
var parse = require('./parse')

module.exports = function (source) {
return parse(scan(source))
module.exports = function (source, validateLicenseNames = true) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typically i'd expect absence and false to be the same for boolean options; this should probably be inverted so it can default to false?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are absolutely right, I will change this.

return parse(scan(source, validateLicenseNames))
}
10 changes: 5 additions & 5 deletions scan.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ var licenses = []
.concat(require('spdx-license-ids/deprecated'))
var exceptions = require('spdx-exceptions')

module.exports = function (source) {
module.exports = function (source, validateLicenseNames = true) {
var index = 0

function hasMore () {
Expand Down Expand Up @@ -85,14 +85,14 @@ module.exports = function (source) {
var begin = index
var string = idstring()

if (licenses.indexOf(string) !== -1) {
if (exceptions.indexOf(string) !== -1) {
return {
type: 'LICENSE',
type: 'EXCEPTION',
string: string
}
} else if (exceptions.indexOf(string) !== -1) {
} else if (licenses.indexOf(string) !== -1 || !validateLicenseNames) {
return {
type: 'EXCEPTION',
type: 'LICENSE',
string: string
}
}
Expand Down