From 7297953f459f6099e7e61f525d52500ccd00a6ed Mon Sep 17 00:00:00 2001 From: Julien Caselmann Date: Tue, 10 Sep 2019 11:29:49 +0200 Subject: [PATCH] Add option to skip validation of license names --- index.js | 4 ++-- scan.js | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/index.js b/index.js index 52fab56..b48b647 100644 --- a/index.js +++ b/index.js @@ -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) { + return parse(scan(source, validateLicenseNames)) } diff --git a/scan.js b/scan.js index b74fce2..4d3d9ca 100644 --- a/scan.js +++ b/scan.js @@ -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 () { @@ -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 } }