New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

license-checker-dkbcodefactory

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

license-checker-dkbcodefactory - npm Package Compare versions

Comparing version 26.0.0 to 26.1.0

tests/fixtures/author/package.json

3

.eslintrc.json
{
"root": true,
"extends": "eslint:recommended",
"parser": "babel-eslint",
"parserOptions": {

@@ -14,3 +15,3 @@ "ecmaVersion": 6,

"semi": 2,
"eqeqeq": [2, "always"],
"eqeqeq": [2, "allow-null"],
"no-console": 0,

@@ -17,0 +18,0 @@ "no-irregular-whitespace": 2,

## Change Log
### upcoming (2020/02/21 15:43 +00:00)
### upcoming (2020/02/22 21:12 +00:00)
- [5ce39aa](https://github.com/RSeidelsohn/license-checker-dkbcodefactory/commit/5ce39aaa546f33b29640ebbee60770b9cf7b1d4b) Run eslit fix, update changelog and remove unreachable code
- [c85149f](https://github.com/RSeidelsohn/license-checker-dkbcodefactory/commit/c85149fc2a025b33a009f172b9a06b6f7c3f4033) Finish refactoring, add options, fix issues

@@ -5,0 +6,0 @@ - [f30bfe4](https://github.com/RSeidelsohn/license-checker-dkbcodefactory/commit/f30bfe4307d584264193e8c041e31478467b2b44) Dumb file right change under Windows...

@@ -29,3 +29,3 @@ /*

out: require('path'),
packages: String,
includePackages: String,
production: Boolean,

@@ -71,3 +71,3 @@ relativeLicensePath: Boolean,

const setDefaults = function setDefaults(parsed) {
if (parsed == undefined) {
if (parsed == null) {
parsed = getCleanParsedArgs();

@@ -77,3 +77,3 @@ }

/*istanbul ignore else*/
if (parsed.color == undefined) {
if (parsed.color == null) {
parsed.color = chalk.supportsColor;

@@ -80,0 +80,0 @@ }

@@ -64,3 +64,3 @@ /*

function include(property) {
return options.customFormat == undefined || options.customFormat[property] !== false;
return options.customFormat == null || options.customFormat[property] !== false;
}

@@ -106,16 +106,2 @@

/*istanbul ignore next*/
if (options.customFormat) {
Object.keys(options.customFormat).forEach(item => {
if (include(item) && json[item]) {
// For now, we only support strings, not JSON objects
if (typeof json[item] === 'string') {
moduleInfo[item] = json[item];
}
} else if (include(item)) {
moduleInfo[item] = options.customFormat[item];
}
});
}
if (include('path') && json.path && typeof json.path === 'string') {

@@ -138,11 +124,11 @@ moduleInfo.path = json.path;

if (Array.isArray(licenseData) && licenseData.length > 0) {
moduleInfo.licenses = licenseData.map(license => {
moduleInfo.licenses = licenseData.map((moduleLicense) => {
/*istanbul ignore else*/
if (typeof license === 'object') {
if (typeof moduleLicense === 'object') {
/*istanbul ignore next*/
return license.type || license.name;
return moduleLicense.type || moduleLicense.name;
}
if (typeof license === 'string') {
return license;
if (typeof moduleLicense === 'string') {
return moduleLicense;
}

@@ -171,3 +157,3 @@ });

noticeFiles = dirFiles.filter(filename => {
noticeFiles = dirFiles.filter((filename) => {
filename = filename.toUpperCase();

@@ -255,3 +241,3 @@ const name = path.basename(filename).replace(path.extname(filename), '');

noticeFiles.forEach(filename => {
noticeFiles.forEach((filename) => {
const file = path.join(json.path, filename);

@@ -266,3 +252,3 @@ /*istanbul ignore else*/

if (json.dependencies) {
Object.keys(json.dependencies).forEach(name => {
Object.keys(json.dependencies).forEach((name) => {
const childDependency = json.dependencies[name];

@@ -294,2 +280,11 @@ const dependencyId = `${childDependency.name}@${childDependency.version}`;

/*istanbul ignore next*/
if (options.customFormat) {
Object.keys(options.customFormat).forEach((item) => {
if (include(item) && moduleInfo[item] == null) {
moduleInfo[item] = typeof json[item] === 'string' ? json[item] : options.customFormat[item];
}
});
}
return data;

@@ -335,3 +330,3 @@ };

if (checker && pusher) {
checker.split(';').forEach(license => {
checker.split(';').forEach((license) => {
const trimmedLicense = license.trim();

@@ -362,3 +357,3 @@ /*istanbul ignore else*/

args.excludeLicenses &&
args.excludeLicenses.match(/([^\\\][^,]|\\,)+/g).map(license => {
args.excludeLicenses.match(/([^\\\][^,]|\\,)+/g).map((license) => {
return license.replace(/\\,/g, ',').replace(/^\s+|\s+$/g, '');

@@ -368,3 +363,3 @@ });

args.includeLicenses &&
args.includeLicenses.match(/([^\\\][^,]|\\,)+/g).map(license => {
args.includeLicenses.match(/([^\\\][^,]|\\,)+/g).map((license) => {
return license.replace(/\\,/g, ',').replace(/^\s+|\s+$/g, '');

@@ -389,9 +384,15 @@ });

Object.keys(filtered).map(package => {
const packageNameParts = package.split('@');
// Some package names start with '@', so we have to include these:
const packageNameOnly = packageNameParts[0] || `@${packageNameParts[1]}`;
if (whitelist.includes(package) || whitelist.includes(packageNameOnly)) {
resultJson[package] = filtered[package];
Object.keys(filtered).map((filteredPackage) => {
// Whitelist packages by declaring:
// 1. the package full name. Ex: `react` (we suffix an '@' to ensure we don't match packages like `react-native`)
// 2. the package full name and the major version. Ex: `react@16`
// 3. the package full name and full version. Ex: `react@16.0.2`
if (
whitelist.findIndex((whitelistPackage) => {
return filteredPackage.startsWith(
whitelistPackage.indexOf('@') > 0 ? whitelistPackage : whitelistPackage + '@'
);
}) !== -1
) {
resultJson[filteredPackage] = filtered[filteredPackage];
}

@@ -406,7 +407,15 @@ });

Object.keys(filtered).map(package => {
const packageNameOnly = package.split('@').shift();
if (!blacklist.includes(package) && !blacklist.includes(packageNameOnly)) {
resultJson[package] = filtered[package];
Object.keys(filtered).map((filteredPackage) => {
// Blacklist packages by declaring:
// 1. the package full name. Ex: `react` (we suffix an '@' to ensure we don't match packages like `react-native`)
// 2. the package full name and the major version. Ex: `react@16`
// 3. the package full name and full version. Ex: `react@16.0.2`
if (
blacklist.findIndex((blacklistPackage) => {
return filteredPackage.startsWith(
blacklistPackage.indexOf('@') > 0 ? blacklistPackage : blacklistPackage + '@'
);
}) === -1
) {
resultJson[filteredPackage] = filtered[filteredPackage];
}

@@ -418,7 +427,7 @@ });

function exitIfCheckHits(package) {
const currentLicense = resultJson[package].licenses;
function exitIfCheckHits(packageName) {
const currentLicense = resultJson[packageName].licenses;
checkForFailOn(currentLicense);
checkForOnlyAllow(currentLicense);
checkForOnlyAllow(currentLicense, packageName);
}

@@ -436,7 +445,7 @@

function checkForOnlyAllow(currentLicense) {
function checkForOnlyAllow(currentLicense, packageName) {
if (toCheckforOnlyAllow.length > 0) {
let hasOnlyAllowedPackages = false;
toCheckforOnlyAllow.forEach(allowedLicense => {
toCheckforOnlyAllow.forEach((allowedLicense) => {
if (currentLicense.indexOf(allowedLicense) >= 0) {

@@ -449,3 +458,3 @@ hasOnlyAllowedPackages = true;

console.error(
`Package "${package}" is licensed under "${currentLicense}" which is not permitted by the --onlyAllow flag. Exiting.`
`Package "${packageName}" is licensed under "${currentLicense}" which is not permitted by the --onlyAllow flag. Exiting.`
);

@@ -458,5 +467,52 @@

function transformBSD(spdx) {
return spdx === 'BSD' ? '(0BSD OR BSD-2-Clause OR BSD-3-Clause OR BSD-4-Clause)' : spdx;
}
function invertResultOf(fn) {
return (spdx) => {
return !fn(spdx);
};
}
function spdxIsValid(spdx) {
return spdxCorrect(spdx) === spdx;
}
function getLicenseMatch(licensesArr, filtered, packageName, packageData, compareLicenses) {
const validSPDXLicenses = compareLicenses.map(transformBSD).filter(spdxIsValid);
const invalidSPDXLicenses = compareLicenses.map(transformBSD).filter(invertResultOf(spdxIsValid));
const spdxExcluder = `( ${validSPDXLicenses.join(' OR ')} )`;
let match = false;
licensesArr.forEach((license) => {
/*istanbul ignore if - just for protection*/
if (license.indexOf(UNKNOWN) >= 0) {
// Necessary due to colorization:
filtered[packageName] = packageData;
} else {
if (license.endsWith('*')) {
license = license.slice(0, -1);
}
license = transformBSD(license);
if (
invalidSPDXLicenses.indexOf(license) >= 0 ||
(spdxCorrect(license) &&
validSPDXLicenses.length > 0 &&
spdxSatisfies(spdxCorrect(license), spdxExcluder))
) {
match = true;
}
}
});
return match;
}
Object.keys(data)
.sort()
.forEach(item => {
.forEach((item) => {
if (data[item].private) {

@@ -502,50 +558,2 @@ data[item].licenses = colorizeString(UNLICENSED);

if (excludeLicenses || includeLicenses) {
function transformBSD(spdx) {
return spdx === 'BSD' ? '(0BSD OR BSD-2-Clause OR BSD-3-Clause OR BSD-4-Clause)' : spdx;
}
function invertResultOf(fn) {
return spdx => {
return !fn(spdx);
};
}
function spdxIsValid(spdx) {
return spdxCorrect(spdx) === spdx;
}
function getLicenseMatch(licensesArr, filtered, packageName, packageData, compareLicenses) {
const validSPDXLicenses = compareLicenses.map(transformBSD).filter(spdxIsValid);
const invalidSPDXLicenses = compareLicenses.map(transformBSD).filter(invertResultOf(spdxIsValid));
const spdxExcluder = `( ${validSPDXLicenses.join(' OR ')} )`;
let match = false;
licensesArr.forEach(license => {
/*istanbul ignore if - just for protection*/
if (license.indexOf(UNKNOWN) >= 0) {
// Necessary due to colorization:
filtered[packageName] = packageData;
} else {
if (license.endsWith('*')) {
license = license.slice(0, -1);
}
license = transformBSD(license);
if (
invalidSPDXLicenses.indexOf(license) >= 0 ||
(spdxCorrect(license) &&
validSPDXLicenses.length > 0 &&
spdxSatisfies(spdxCorrect(license), spdxExcluder))
) {
// console.log(`License ${JSON.stringify(license)} match with ${compareLicenses}!`);
match = true;
}
}
});
// console.log(`License ${JSON.stringify(license)} DO NOT match with ${compareLicenses}!`);
return match;
}
if (excludeLicenses) {

@@ -605,4 +613,4 @@ Object.entries(sorted).forEach(([packageName, packageData]) => {

// package whitelist
if (args.packages) {
const whitelist = args.packages.split(';');
const whitelist = getOptionArray(args.includePackages);
if (whitelist) {
resultJson = onlyIncludeWhitelist(whitelist, filtered);

@@ -612,4 +620,4 @@ }

// package blacklist
if (args.excludePackages) {
const blacklist = args.excludePackages.split(';');
const blacklist = getOptionArray(args.excludePackages);
if (blacklist) {
resultJson = excludeBlacklist(blacklist, filtered);

@@ -644,3 +652,3 @@ }

exports.asSummary = function asSummary(sorted) {
const licenseCountMap = new Map();
const licenseCountMap = new global.Map();
const licenseCountArray = [];

@@ -687,9 +695,9 @@ const sortedLicenseCountObj = {};

exports.asMarkDown = function asMarkDown(sorted, customFormat) {
const text = [];
let text = [];
if (customFormat && Object.keys(customFormat).length > 0) {
Object.keys(sorted).forEach(sortedItem => {
Object.keys(sorted).forEach((sortedItem) => {
text.push(` - **[${sortedItem}](${sorted[sortedItem].repository})**`);
Object.keys(customFormat).forEach(customItem => {
Object.keys(customFormat).forEach((customItem) => {
text.push(` - ${customItem}: ${sorted[sortedItem][customItem]}`);

@@ -701,3 +709,3 @@ });

} else {
Object.keys(sorted).forEach(key => {
Object.keys(sorted).forEach((key) => {
const module = sorted[key];

@@ -719,3 +727,3 @@ text.push(`[${key}](${module.repository}) - ${module.licenses}`);

try {
jsonFileContents = fs.readFileSync(jsonPath, { encoding: 'utf8' });
const jsonFileContents = fs.readFileSync(jsonPath, { encoding: 'utf8' });

@@ -731,3 +739,3 @@ return JSON.parse(jsonFileContents);

Object.keys(json).forEach(moduleName => {
Object.keys(json).forEach((moduleName) => {
const licenseFile = json[moduleName].licenseFile;

@@ -759,7 +767,7 @@

Object.keys(customFormat).forEach(item => {
Object.keys(customFormat).forEach((item) => {
entriesArr.push(`"${item}"`);
});
} else {
['"module name"', '"license"', '"repository"'].forEach(item => {
['"module name"', '"license"', '"repository"'].forEach((item) => {
entriesArr.push(item);

@@ -786,3 +794,3 @@ });

Object.keys(customFormat).forEach(item => {
Object.keys(customFormat).forEach((item) => {
dataElements.push(`"${module[item]}"`);

@@ -799,1 +807,5 @@ });

}
function getOptionArray(option) {
return (Array.isArray(option) && option) || (typeof option === 'string' && option.split(';')) || false;
}

@@ -13,3 +13,3 @@ const spdxExpressionParse = require('spdx-expression-parse');

const LGPL = /(?:LESSER|LIBRARY) GENERAL PUBLIC LICENSE\s*Version ([^,]*)/i;
const APACHE_VERSION = /\bApache License\s*Version ([^,]*)/i;
const APACHE_VERSION = /\bApache License\s*Version ([^,\s]*)/i;
const APACHE = /\bApache License\b/;

@@ -19,9 +19,9 @@ const WTFPL = /\bWTFPL\b/;

const CC0_1_0 = /The\s+person\s+who\s+associated\s+a\s+work\s+with\s+this\s+deed\s+has\s+dedicated\s+the\s+work\s+to\s+the\s+public\s+domain\s+by\s+waiving\s+all\s+of\s+his\s+or\s+her\s+rights\s+to\s+the\s+work\s+worldwide\s+under\s+copyright\s+law,\s+including\s+all\s+related\s+and\s+neighboring\s+rights,\s+to\s+the\s+extent\s+allowed\s+by\s+law.\s+You\s+can\s+copy,\s+modify,\s+distribute\s+and\s+perform\s+the\s+work,\s+even\s+for\s+commercial\s+purposes,\s+all\s+without\s+asking\s+permission./i; // jshint ignore:line
const PUBLIC_DOMAIN = /[Pp]ublic [Dd]omain/;
const PUBLIC_DOMAIN = /[Pp]ublic[\-_ ]*[Dd]omain/;
const IS_URL = /(https?:\/\/[-a-zA-Z0-9\/.]*)/;
const IS_FILE_REFERENCE = /SEE LICENSE IN (.*)/i;
module.exports = function exports(str) {
module.exports = function exports(str = 'undefined') {
if (typeof str !== 'string') {
throw new Error(`Wrong type for parameter "str" ("${str}"): Must be of type string`, 'license.js', 23);
throw new Error(`Wrong type for parameter "str" ("${str}"): Must be of type string`, 'lib/license.js', 24);
}

@@ -43,3 +43,3 @@

if (typeof str === 'undefined' || !str) {
if (typeof str === 'undefined' || !str || str === 'undefined') {
return 'Undefined';

@@ -46,0 +46,0 @@ }

@@ -5,3 +5,3 @@ {

"author": "Roman Seidelsohn <rseidelsohn@gmail.com>",
"version": "26.0.0",
"version": "26.1.0",
"contributors": [

@@ -43,2 +43,3 @@ "Adam Weber <adamweber01@gmail.com>",

"Roman Seidelsohn <rseidelsohn@gmail.com>",
"Roman Seidelsohn <rseidelsohn@rbloeth.de>",
"Stan Senotrusov <stan@senotrusov.com>",

@@ -77,2 +78,3 @@ "Stoyan Revov <st.revov@gmail.com>",

"@types/node": "^13.7.4",
"babel-eslint": "^10.0.3",
"camden.jshint": "github:cfjedimaster/brackets-jshint",

@@ -125,4 +127,4 @@ "detectionizr": "*",

"functions": 100,
"branches": 99
"branches": 96
}
}

@@ -73,23 +73,25 @@ # NPM License Checker

- `--production` only show production dependencies.
- `--development` only show development dependencies.
- `--start [path of the initial json to look for]`
- `--unknown` report guessed licenses as unknown licenses.
- `--onlyunknown` only list packages with unknown or guessed licenses.
- `--json` output in json format.
- `--csv` output in csv format.
- `--csvComponentPrefix` prefix column for component in csv format.
- `--out [filepath]` write the data to a specific file.
- `--customPath` to add a custom Format file in JSON
- `--excludeLicenses [list]` exclude modules which licenses are in the comma-separated list from the output
- `--includeLicenses [list]` include only modules which licenses are in the comma-separated list from the output
- `--relativeLicensePath` output the location of the license files as relative paths
- `--relativeModulePath` output the location of the module files as relative paths
- `--summary` output a summary of the license usage',
- `--failOn [list]` fail (exit with code 1) on the first occurrence of the licenses of the semicolon-separated list
- `--onlyAllow [list]` fail (exit with code 1) on the first occurrence of the licenses not in the semicolon-seperated list
- `--packages [list]` restrict output to the packages (either "package@version" or only "package") in the semicolon-seperated list
- `--excludePackages [list]` restrict output to the packages (either "package@version" or only "package") not in the semicolon-seperated list
- `--excludePrivatePackages` restrict output to not include any package marked as private
- `--direct look for direct dependencies only`
- `--production` only show production dependencies.
- `--development` only show development dependencies.
- `--start [filepath]` path of the initial json to look for
- `--unknown` report guessed licenses as unknown licenses.
- `--onlyunknown` only list packages with unknown or guessed licenses.
- `--markdown` output in markdown format.
- `--json` output in json format.
- `--csv` output in csv format.
- `--csvComponentPrefix` prefix column for component in csv format.
- `--out [filepath]` write the data to a specific file.
- `--files [path]` copy all license files to path and rename them to `module-name`@`version`-LICENSE.txt.
- `--customPath` to add a custom Format file in JSON
- `--excludeLicenses [list]` exclude modules which licenses are in the comma-separated list from the output
- `--includeLicenses [list]` include only modules which licenses are in the comma-separated list from the output
- `--relativeLicensePath` output the location of the license files as relative paths
- `--relativeModulePath` output the location of the module files as relative paths
- `--summary` output a summary of the license usage',
- `--failOn [list]` fail (exit with code 1) on the first occurrence of the licenses of the semicolon-separated list
- `--onlyAllow [list]` fail (exit with code 1) on the first occurrence of the licenses not in the semicolon-seperated list
- `--includePackages [list]` restrict output to the packages (either "package@fullversion" or "package@majorversion" or only "package") in the semicolon-seperated list
- `--excludePackages [list]` restrict output to the packages (either "package@fullversion" or "package@majorversion" or only "package") not in the semicolon-seperated list
- `--excludePrivatePackages` restrict output to not include any package marked as private
- `--direct` look for direct dependencies only

@@ -113,3 +115,3 @@ ## Exclusions

license-checker-dkbcodefactory --excludeModules 'MIT, MIT OR X11, BSD, ISC'
license-checker-dkbcodefactory --packages 'react@16.3.0;react-dom@16.3.0;lodash@4.3.1'
license-checker-dkbcodefactory --includePackages 'react@16.3.0;react-dom@16.3.0;lodash@4.3.1'
license-checker-dkbcodefactory --excludePackages 'internal-1;internal-2'

@@ -128,13 +130,13 @@ license-checker-dkbcodefactory --onlyunknown

- name
- version
- description
- repository
- publisher
- email
- url
- licenses
- licenseFile
- licenseText
- licenseModified
- name
- version
- description
- repository
- publisher
- email
- url
- licenses
- licenseFile
- licenseText
- licenseModified

@@ -150,13 +152,13 @@ You can also give default values for each item.

checker.init(
{
start: '/path/to/start/looking',
},
function(err, packages) {
if (err) {
//Handle error
} else {
//The sorted package data
//as an Object
}
{
start: '/path/to/start/looking',
},
function(err, packages) {
if (err) {
//Handle error
} else {
//The sorted package data
//as an Object
}
}
);

@@ -169,4 +171,4 @@ ```

- `license-checker-dkbcodefactory:error` for errors
- `license-checker-dkbcodefactory:log` for non-errors
- `license-checker-dkbcodefactory:error` for errors
- `license-checker-dkbcodefactory:log` for non-errors

@@ -173,0 +175,0 @@ Set the `DEBUG` environment variable to one of these to see debug output:

@@ -5,8 +5,8 @@ var assert = require('assert'),

describe('bin/license-checker', function() {
describe('bin/license-checker-dkbcodefactory', function() {
this.timeout(8000);
it('should exit 0', function(done) {
spawn('node', [path.join(__dirname, '../bin/license-checker')], {
spawn('node', [path.join(__dirname, '../bin/license-checker-dkbcodefactory')], {
cwd: path.join(__dirname, '../'),
stdio: 'ignore'
stdio: 'ignore',
}).on('exit', function(code) {

@@ -17,3 +17,2 @@ assert.equal(code, 0);

});
});

@@ -5,8 +5,8 @@ var assert = require('assert'),

describe('bin/license-checker', function() {
describe('bin/license-checker-dkbcodefactory', function() {
this.timeout(8000);
it('should exit 1 if it finds a single license type (MIT) license due to --failOn MIT', function(done) {
spawn('node', [path.join(__dirname, '../bin/license-checker'), '--failOn', 'MIT'], {
spawn('node', [path.join(__dirname, '../bin/license-checker-dkbcodefactory'), '--failOn', 'MIT'], {
cwd: path.join(__dirname, '../'),
stdio: 'ignore'
stdio: 'ignore',
}).on('exit', function(code) {

@@ -19,5 +19,5 @@ assert.equal(code, 1);

it('should exit 1 if it finds forbidden licenses license due to --failOn MIT;ISC', function(done) {
spawn('node', [path.join(__dirname, '../bin/license-checker'), '--failOn', 'MIT;ISC'], {
spawn('node', [path.join(__dirname, '../bin/license-checker-dkbcodefactory'), '--failOn', 'MIT;ISC'], {
cwd: path.join(__dirname, '../'),
stdio: 'ignore'
stdio: 'ignore',
}).on('exit', function(code) {

@@ -30,8 +30,12 @@ assert.equal(code, 1);

it('should give warning about commas if --failOn MIT,ISC is provided', function(done) {
var proc = spawn('node', [path.join(__dirname, '../bin/license-checker'), '--failOn', 'MIT,ISC'], {
cwd: path.join(__dirname, '../'),
stdio: 'pipe'
});
var proc = spawn(
'node',
[path.join(__dirname, '../bin/license-checker-dkbcodefactory'), '--failOn', 'MIT,ISC'],
{
cwd: path.join(__dirname, '../'),
stdio: 'pipe',
}
);
var stderr = '';
proc.stdout.on('data', function() { });
proc.stdout.on('data', function() {});
proc.stderr.on('data', function(data) {

@@ -41,3 +45,6 @@ stderr += data.toString();

proc.on('close', function() {
assert.equal(stderr.indexOf('--failOn argument takes semicolons as delimeters instead of commas') >= 0, true);
assert.equal(
stderr.indexOf('--failOn argument takes semicolons as delimeters instead of commas') >= 0,
true
);
done();

@@ -44,0 +51,0 @@ });

var assert = require('assert'),
util = require('util'),
license = require('../lib/license');
describe('license parser', function() {
it('should export a function', function() {

@@ -10,2 +10,15 @@ assert.equal(typeof license, 'function');

it('should throw an error when called with a non-string argument', function(done) {
try {
license({});
} catch (err) {
assert.ok(util.isError(err));
done();
}
});
it('removes newlines from the argument', function() {
assert.equal(license('unde\nfined'), 'Undefined');
});
it('undefined check', function() {

@@ -66,3 +79,5 @@ assert.equal(license(undefined), 'Undefined');

it('BSD-Source-Code check', function() {
var data = license('asdf\nRedistribution and use of this software in source and binary forms, with or without modification, are permitted provided that the following conditions are met:\nasdf\n');
var data = license(
'asdf\nRedistribution and use of this software in source and binary forms, with or without modification, are permitted provided that the following conditions are met:\nasdf\n'
);
assert.equal(data, 'BSD-Source-Code*');

@@ -75,3 +90,3 @@ });

});
it('Non-BSD word check', function() {

@@ -82,2 +97,7 @@ var data = license('prefixBSD\n');

it('Apache version check', function() {
var data = license('asdf\nasdf\nApache License Version 2\nasdf\n');
assert.equal(data, 'Apache-2.0*');
});
it('Apache word check', function() {

@@ -87,3 +107,3 @@ var data = license('asdf\nasdf\nApache License\nasdf\n');

});
it('Non-Apache word check', function() {

@@ -103,3 +123,3 @@ var data = license('prefixApache License\n');

});
it('Non-WTF word check', function() {

@@ -126,3 +146,5 @@ var data = license('prefixWTFPL\n');

it('CC0-1.0 word check', function() {
var data = license('The person who associated a work with this deed has dedicated the work to the public domain by waiving all of his or her rights to the work worldwide under copyright law, including all related and neighboring rights, to the extent allowed by law.\n\nYou can copy, modify, distribute and perform the work, even for commercial purposes, all without asking permission.\n');
var data = license(
'The person who associated a work with this deed has dedicated the work to the public domain by waiving all of his or her rights to the work worldwide under copyright law, including all related and neighboring rights, to the extent allowed by law.\n\nYou can copy, modify, distribute and perform the work, even for commercial purposes, all without asking permission.\n'
);
assert.equal(data, 'CC0-1.0*');

@@ -138,2 +160,6 @@ });

assert.equal(data, 'Public Domain');
data = license('Public-Domain');
assert.equal(data, 'Public Domain');
data = license('Public_Domain');
assert.equal(data, 'Public Domain');
});

@@ -157,3 +183,2 @@

it('Check for null', function() {

@@ -165,10 +190,4 @@ var data = license('this is empty, hi');

describe('SPDX licenses', function() {
it('should parse a basic SPDX license', function() {
var data = [
'MIT',
'LGPL-2.0',
'Apache-2.0',
'BSD-2-Clause'
];
var data = ['MIT', 'LGPL-2.0', 'Apache-2.0', 'BSD-2-Clause'];
data.forEach(function(licenseType) {

@@ -188,6 +207,4 @@ assert.equal(license(licenseType), licenseType);

});
});
});
});

@@ -5,12 +5,19 @@ var assert = require('assert'),

describe('bin/license-checker', function() {
describe('bin/license-checker-dkbcodefactory', function() {
this.timeout(8000);
it('should restrict the output to the provided packages', function() {
var restrictedPackages = [
'readable-stream@1.1.14'
];
var output = spawn('node', [path.join(__dirname, '../bin/license-checker'), '--json', '--packages', restrictedPackages.join(';')], {
cwd: path.join(__dirname, '../'),
});
var restrictedPackages = ['readable-stream@1.1.14'];
var output = spawn(
'node',
[
path.join(__dirname, '../bin/license-checker-dkbcodefactory'),
'--json',
'--includePackages',
restrictedPackages.join(';'),
],
{
cwd: path.join(__dirname, '../'),
}
);

@@ -21,10 +28,15 @@ assert.deepEqual(Object.keys(JSON.parse(output.stdout.toString())), restrictedPackages);

it('should exclude provided excludedPackages from the output', function() {
var excludedPackages = [
'readable-stream@1.1.14',
'spdx-satisfies@4.0.0',
'y18n@3.2.1',
];
var output = spawn('node', [path.join(__dirname, '../bin/license-checker'), '--json', '--excludePackages', excludedPackages.join(';')], {
cwd: path.join(__dirname, '../'),
});
var excludedPackages = ['readable-stream@1.1.14', 'spdx-satisfies@4.0.0', 'y18n@3.2.1'];
var output = spawn(
'node',
[
path.join(__dirname, '../bin/license-checker-dkbcodefactory'),
'--json',
'--excludePackages',
excludedPackages.join(';'),
],
{
cwd: path.join(__dirname, '../'),
}
);

@@ -38,5 +50,9 @@ var packages = Object.keys(JSON.parse(output.stdout.toString()));

it('should exclude private packages from the output', function() {
var output = spawn('node', [path.join(__dirname, '../bin/license-checker'), '--json', '--excludePrivatePackages'], {
cwd: path.join(__dirname, 'fixtures', 'privateModule'),
});
var output = spawn(
'node',
[path.join(__dirname, '../bin/license-checker-dkbcodefactory'), '--json', '--excludePrivatePackages'],
{
cwd: path.join(__dirname, 'fixtures', 'privateModule'),
}
);

@@ -43,0 +59,0 @@ var packages = Object.keys(JSON.parse(output.stdout.toString()));

@@ -22,8 +22,11 @@ var assert = require('assert'),

this.timeout(5000);
checker.init({
start: path.join(__dirname, '../')
}, function(err, sorted) {
output = sorted;
done();
});
checker.init(
{
start: path.join(__dirname, '../'),
},
function(err, sorted) {
output = sorted;
done();
}
);
});

@@ -39,7 +42,13 @@

assert.equal('"module name","license","repository"', str.split('\n')[0]);
assert.equal('"@babel/code-frame@7.5.5","MIT","https://github.com/babel/babel/tree/master/packages/babel-code-frame"', str.split('\n')[1]);
assert.equal(
'"@babel/code-frame@7.5.5","MIT","https://github.com/babel/babel/tree/master/packages/babel-code-frame"',
str.split('\n')[1]
);
});
it('and convert to MarkDown', function() {
var str = checker.asMarkDown(output);
assert.equal('[@babel/code-frame@7.5.5](https://github.com/babel/babel/tree/master/packages/babel-code-frame) - MIT', str.split('\n')[0]);
assert.equal(
'[@babel/code-frame@7.5.5](https://github.com/babel/babel/tree/master/packages/babel-code-frame) - MIT',
str.split('\n')[0]
);
});

@@ -52,14 +61,17 @@ });

var format = {
'name': '<<Default Name>>',
'description': '<<Default Description>>',
'pewpew': '<<Should Never be set>>'
name: '<<Default Name>>',
description: '<<Default Description>>',
pewpew: '<<Should Never be set>>',
};
checker.init({
start: path.join(__dirname, '../'),
customFormat: format
}, function(err, sorted) {
output = sorted;
done();
});
checker.init(
{
start: path.join(__dirname, '../'),
customFormat: format,
},
function(err, sorted) {
output = sorted;
done();
}
);
});

@@ -69,3 +81,3 @@

assert.ok(Object.keys(output).length > 70);
assert.equal(output['abbrev@1.0.9'].description, 'Like ruby\'s abbrev module, but in js');
assert.equal(output['abbrev@1.0.9'].description, "Like ruby's abbrev module, but in js");
});

@@ -75,5 +87,5 @@

var format = {
'name': '<<Default Name>>',
'description': '<<Default Description>>',
'pewpew': '<<Should Never be set>>'
name: '<<Default Name>>',
description: '<<Default Description>>',
pewpew: '<<Should Never be set>>',
};

@@ -83,3 +95,6 @@

assert.equal('"module name","name","description","pewpew"', str.split('\n')[0]);
assert.equal('"@babel/code-frame@7.5.5","@babel/code-frame","Generate errors that contain a code frame that point to source locations.","<<Should Never be set>>"', str.split('\n')[1]);
assert.equal(
'"@babel/code-frame@7.5.5","@babel/code-frame","Generate errors that contain a code frame that point to source locations.","<<Should Never be set>>"',
str.split('\n')[1]
);
});

@@ -89,11 +104,13 @@

var format = {
'name': '<<Default Name>>',
'description': '<<Default Description>>',
'pewpew': '<<Should Never be set>>'
name: '<<Default Name>>',
description: '<<Default Description>>',
pewpew: '<<Should Never be set>>',
};
var str = checker.asCSV(output, format, "main-module");
var str = checker.asCSV(output, format, 'main-module');
assert.equal('"component","module name","name","description","pewpew"', str.split('\n')[0]);
assert.equal('"main-module","@babel/code-frame@7.5.5","@babel/code-frame","Generate errors that contain a code frame that point to source locations.","<<Should Never be set>>"', str.split('\n')[1]);
assert.equal(
'"main-module","@babel/code-frame@7.5.5","@babel/code-frame","Generate errors that contain a code frame that point to source locations.","<<Should Never be set>>"',
str.split('\n')[1]
);
});

@@ -103,9 +120,12 @@

var format = {
'name': '<<Default Name>>',
'description': '<<Default Description>>',
'pewpew': '<<Should Never be set>>'
name: '<<Default Name>>',
description: '<<Default Description>>',
pewpew: '<<Should Never be set>>',
};
var str = checker.asMarkDown(output, format);
assert.equal(' - **[@babel/code-frame@7.5.5](https://github.com/babel/babel/tree/master/packages/babel-code-frame)**', str.split('\n')[0]);
assert.equal(
' - **[@babel/code-frame@7.5.5](https://github.com/babel/babel/tree/master/packages/babel-code-frame)**',
str.split('\n')[0]
);
});

@@ -117,9 +137,12 @@ });

before(function(done) {
checker.init({
start: path.join(__dirname, '../'),
unknown: true
}, function(err, sorted) {
output = sorted;
done();
});
checker.init(
{
start: path.join(__dirname, '../'),
unknown: true,
},
function(err, sorted) {
output = sorted;
done();
}
);
});

@@ -135,9 +158,12 @@

return function(done) {
checker.init({
start: path.join(__dirname, parsePath),
exclude: licenses
}, function(err, filtered) {
result.output = filtered;
done();
});
checker.init(
{
start: path.join(__dirname, parsePath),
excludeLicenses: licenses,
},
function(err, filtered) {
result.output = filtered;
done();
}
);
};

@@ -147,4 +173,4 @@ }

describe('should parse local with unknown and excludes', function() {
var result={};
before(parseAndExclude('../', "MIT, ISC", result));
var result = {};
before(parseAndExclude('../', 'MIT, ISC', result));

@@ -155,3 +181,3 @@ it('should exclude MIT and ISC licensed modules from results', function() {

Object.keys(output).forEach(function(item) {
if (output[item].licenses && (output[item].licenses === "MIT" || output[item].licenses === "ISC"))
if (output[item].licenses && (output[item].licenses === 'MIT' || output[item].licenses === 'ISC'))
excluded = false;

@@ -164,4 +190,4 @@ });

describe('should parse local with excludes containing commas', function() {
var result={};
before(parseAndExclude('./fixtures/excludeWithComma', "Apache License\\, Version 2.0", result));
var result = {};
before(parseAndExclude('./fixtures/excludeWithComma', 'Apache License\\, Version 2.0', result));

@@ -172,4 +198,3 @@ it('should exclude a license with a comma from the list', function() {

Object.keys(output).forEach(function(item) {
if (output[item].licenses && output[item].licenses === "Apache License, Version 2.0")
excluded = false;
if (output[item].licenses && output[item].licenses === 'Apache License, Version 2.0') excluded = false;
});

@@ -181,6 +206,5 @@ assert.ok(excluded);

describe('should parse local with BSD excludes', function() {
var result={};
before(parseAndExclude('./fixtures/excludeBSD', "BSD", result));
var result = {};
before(parseAndExclude('./fixtures/excludeBSD', 'BSD', result));
it('should exclude BSD-3-Clause', function() {

@@ -190,4 +214,3 @@ var excluded = true;

Object.keys(output).forEach(function(item) {
if (output[item].licenses && output[item].licenses === "BSD-3-Clause")
excluded = false;
if (output[item].licenses && output[item].licenses === 'BSD-3-Clause') excluded = false;
});

@@ -199,6 +222,5 @@ assert.ok(excluded);

describe('should parse local with Public Domain excludes', function() {
var result={};
before(parseAndExclude('./fixtures/excludePublicDomain', "Public Domain", result));
var result = {};
before(parseAndExclude('./fixtures/excludePublicDomain', 'Public Domain', result));
it('should exclude Public Domain', function() {

@@ -208,4 +230,3 @@ var excluded = true;

Object.keys(output).forEach(function(item) {
if (output[item].licenses && output[item].licenses === "Public Domain")
excluded = false;
if (output[item].licenses && output[item].licenses === 'Public Domain') excluded = false;
});

@@ -217,6 +238,5 @@ assert.ok(excluded);

describe('should not exclude Custom if not specified in excludes', function() {
var result={};
before(parseAndExclude('./fixtures/custom-license-file', "MIT", result));
var result = {};
before(parseAndExclude('./fixtures/custom-license-file', 'MIT', result));
it('should exclude Public Domain', function() {

@@ -226,4 +246,3 @@ var excluded = true;

Object.keys(output).forEach(function(item) {
if (output[item].licenses && output[item].licenses === "Custom: MY-LICENSE.md")
excluded = false;
if (output[item].licenses && output[item].licenses === 'Custom: MY-LICENSE.md') excluded = false;
});

@@ -241,3 +260,3 @@ assert.ok(!excluded);

var config = {
start: path.join(__dirname, parsePath)
start: path.join(__dirname, parsePath),
};

@@ -254,4 +273,4 @@ config[key] = licenses;

describe('should exit on given list of onlyAllow licenses', function() {
var result={};
before(parseAndFailOn('onlyAllow', '../', "MIT; ISC", result));
var result = {};
before(parseAndFailOn('onlyAllow', '../', 'MIT; ISC', result));

@@ -264,4 +283,4 @@ it('should exit on non MIT and ISC licensed modules from results', function() {

describe('should exit on single onlyAllow license', function() {
var result={};
before(parseAndFailOn('onlyAllow', '../', "ISC", result));
var result = {};
before(parseAndFailOn('onlyAllow', '../', 'ISC', result));

@@ -274,8 +293,15 @@ it('should exit on non ISC licensed modules from results', function() {

describe('should not exit on complete list', function() {
var result={};
before(parseAndFailOn('onlyAllow', '../', "MIT;ISC;MIT;BSD-3-Clause;BSD;Apache-2.0;" +
"BSD-2-Clause;Apache*;BSD*;CC-BY-3.0;Unlicense;CC0-1.0;The MIT License;AFLv2.1,BSD;" +
"Public Domain;Custom: http://i.imgur.com/goJdO.png;WTFPL*;Apache License, Version 2.0;" +
"WTFPL;(MIT AND CC-BY-3.0);Custom: https://github.com/substack/node-browserify;" +
"BSD-3-Clause OR MIT;(WTFPL OR MIT)", result));
var result = {};
before(
parseAndFailOn(
'onlyAllow',
'../',
'MIT;ISC;MIT;BSD-3-Clause;BSD;Apache-2.0;' +
'BSD-2-Clause;Apache*;BSD*;CC-BY-3.0;Unlicense;CC0-1.0;The MIT License;AFLv2.1,BSD;' +
'Public Domain;Custom: http://i.imgur.com/goJdO.png;WTFPL*;Apache License, Version 2.0;' +
'WTFPL;(MIT AND CC-BY-3.0);Custom: https://github.com/substack/node-browserify;' +
'BSD-3-Clause OR MIT;(WTFPL OR MIT)',
result
)
);

@@ -288,4 +314,4 @@ it('should not exist if list is complete', function() {

describe('should exit on given list of failOn licenses', function() {
var result={};
before(parseAndFailOn('failOn', '../', "MIT; ISC", result));
var result = {};
before(parseAndFailOn('failOn', '../', 'MIT; ISC', result));

@@ -298,4 +324,4 @@ it('should exit on MIT and ISC licensed modules from results', function() {

describe('should exit on single failOn license', function() {
var result={};
before(parseAndFailOn('failOn', '../', "ISC", result));
var result = {};
before(parseAndFailOn('failOn', '../', 'ISC', result));

@@ -310,8 +336,11 @@ it('should exit on ISC licensed modules from results', function() {

before(function(done) {
checker.init({
start: path.join(__dirname, './fixtures/privateModule'),
}, function(err, filtered) {
output = filtered;
done();
});
checker.init(
{
start: path.join(__dirname, './fixtures/privateModule'),
},
function(err, filtered) {
output = filtered;
done();
}
);
});

@@ -322,3 +351,3 @@

Object.keys(output).forEach(function(item) {
if (output[item].licenses && output[item].licenses.indexOf("UNLICENSED") >=0) {
if (output[item].licenses && output[item].licenses.indexOf('UNLICENSED') >= 0) {
privateModule = true;

@@ -332,11 +361,13 @@ }

describe('should treat license file over custom urls', function() {
it('should recognise a custom license at a url', function(done) {
checker.init({
start: path.join(__dirname, '../node_modules/locale')
}, function(err, output) {
var item = output[Object.keys(output)[0]];
assert.equal(item.licenses, 'MIT*');
done();
});
checker.init(
{
start: path.join(__dirname, '../node_modules/locale'),
},
function(err, output) {
var item = output[Object.keys(output)[0]];
assert.equal(item.licenses, 'MIT*');
done();
}
);
});

@@ -348,8 +379,11 @@ });

before(function(done) {
checker.init({
start: path.join(__dirname, './fixtures/custom-license-url')
}, function(err, filtered) {
output = filtered;
done();
});
checker.init(
{
start: path.join(__dirname, './fixtures/custom-license-url'),
},
function(err, filtered) {
output = filtered;
done();
}
);
});

@@ -360,3 +394,3 @@

Object.keys(output).forEach(function(item) {
if (output[item].licenses && (output[item].licenses === "Custom: http://example.com/dummy-license"))
if (output[item].licenses && output[item].licenses === 'Custom: http://example.com/dummy-license')
foundCustomLicense = true;

@@ -371,8 +405,11 @@ });

before(function(done) {
checker.init({
start: path.join(__dirname, './fixtures/custom-license-file')
}, function(err, filtered) {
output = filtered;
done();
});
checker.init(
{
start: path.join(__dirname, './fixtures/custom-license-file'),
},
function(err, filtered) {
output = filtered;
done();
}
);
});

@@ -383,3 +420,3 @@

Object.keys(output).forEach(function(item) {
if (output[item].licenses && (output[item].licenses === "Custom: MY-LICENSE.md"))
if (output[item].licenses && output[item].licenses === 'Custom: MY-LICENSE.md')
foundCustomLicense = true;

@@ -393,18 +430,24 @@ });

it('should init without errors', function(done) {
checker.init({
start: path.join(__dirname, '../'),
development: true
}, function(err) {
assert.equal(err, null);
done();
});
checker.init(
{
start: path.join(__dirname, '../'),
development: true,
},
function(err) {
assert.equal(err, null);
done();
}
);
});
it('should init with errors (npm packages not found)', function(done) {
checker.init({
start: 'C:\\'
}, function(err) {
assert.ok(util.isError(err));
done();
});
checker.init(
{
start: 'C:\\',
},
function(err) {
assert.ok(util.isError(err));
done();
}
);
});

@@ -444,3 +487,3 @@ });

color: undefined,
start: path.resolve(path.join(__dirname, '../'))
start: path.resolve(path.join(__dirname, '../')),
};

@@ -455,20 +498,22 @@ def[type] = true;

describe('custom formats', function() {
it('should create a custom format using customFormat successfully', function(done) {
checker.init({
start: path.join(__dirname, '../'),
customFormat: {
'name': '<<Default Name>>',
'description': '<<Default Description>>',
'pewpew': '<<Should Never be set>>'
checker.init(
{
start: path.join(__dirname, '../'),
customFormat: {
name: '<<Default Name>>',
description: '<<Default Description>>',
pewpew: '<<Should Never be set>>',
},
},
function(err, d) {
Object.keys(d).forEach(function(item) {
assert.notEqual(d[item].name, undefined);
assert.notEqual(d[item].description, undefined);
assert.notEqual(d[item].pewpew, undefined);
assert.equal(d[item].pewpew, '<<Should Never be set>>');
});
done();
}
}, function(err, d) {
Object.keys(d).forEach(function(item) {
assert.notEqual(d[item].name, undefined);
assert.notEqual(d[item].description, undefined);
assert.notEqual(d[item].pewpew, undefined);
assert.equal(d[item].pewpew, '<<Should Never be set>>');
});
done();
});
);
});

@@ -487,3 +532,6 @@

checker.init(args, function(err, filtered) {
var customFormatContent = fs.readFileSync(path.join(__dirname, './../customFormatExample.json'), 'utf8');
var customFormatContent = fs.readFileSync(
path.join(__dirname, './../customFormatExample.json'),
'utf8'
);

@@ -505,31 +553,51 @@ assert.notEqual(customFormatContent, undefined);

it('should return data for keys with different names in json vs custom format', function(done) {
checker.init(
{
start: path.join(__dirname, './fixtures/author'),
customFormat: {
publisher: '',
},
},
function(err, filtered) {
assert.equal(Object.keys(filtered).length, 1);
assert.equal(filtered['license-checker-dkbcodefactory@0.0.0'].publisher, 'Roman Seidelsohn');
done();
}
);
});
});
describe('should output the module location', function() {
it('as absolute path', function(done) {
checker.init({
start: path.join(__dirname, '../')
}, function(err, output) {
Object.keys(output).map(function(key) {
var expectedPath = path.join(__dirname, '../');
var actualPath = output[key].path.substr(0, expectedPath.length);
assert.equal(actualPath, expectedPath);
});
done();
});
checker.init(
{
start: path.join(__dirname, '../'),
},
function(err, output) {
Object.keys(output).map(function(key) {
var expectedPath = path.join(__dirname, '../');
var actualPath = output[key].path.substr(0, expectedPath.length);
assert.equal(actualPath, expectedPath);
});
done();
}
);
});
it('as relative paths when using relativeModulePath', function(done) {
checker.init({
start: path.join(__dirname, '../node_modules'),
relativeModulePath: true
}, function(err, output) {
Object.keys(output).map(function(key) {
var expectedPath = 'node_modules';
var actualPath = output[key].path.substr(0, expectedPath.length);
assert.equal(actualPath, expectedPath);
});
done();
});
checker.init(
{
start: path.join(__dirname, '../node_modules/'),
relativeModulePath: true,
},
function(err, output) {
Object.keys(output).map(function(key) {
var expectedPath = 'node_modules/';
var actualPath = output[key].path.substr(0, expectedPath.length);
assert.equal(actualPath, expectedPath);
});
done();
}
);
});

@@ -539,57 +607,68 @@ });

describe('should output the location of the license files', function() {
it('as absolute paths', function(done) {
checker.init({
start: path.join(__dirname, '../')
}, function(err, output) {
Object.keys(output).map(function(key) {
return output[key];
}).filter(function(dep) {
return dep.licenseFile !== undefined;
}).forEach(function(dep) {
var expectedPath = path.join(__dirname, '../');
var actualPath = dep.licenseFile.substr(0, expectedPath.length);
assert.equal(actualPath, expectedPath);
});
done();
});
checker.init(
{
start: path.join(__dirname, '../'),
},
function(err, output) {
Object.keys(output)
.map(function(key) {
return output[key];
})
.filter(function(dep) {
return dep.licenseFile !== undefined;
})
.forEach(function(dep) {
var expectedPath = path.join(__dirname, '../');
var actualPath = dep.licenseFile.substr(0, expectedPath.length);
assert.equal(actualPath, expectedPath);
});
done();
}
);
});
it('as relative paths when using relativeLicensePath', function(done) {
checker.init({
start: path.join(__dirname, '../'),
relativeLicensePath: true
}, function(err, filtered) {
Object.keys(filtered).map(function(key) {
return filtered[key];
}).filter(function(dep) {
return dep.licenseFile !== undefined;
}).forEach(function(dep) {
assert.notEqual(dep.licenseFile.substr(0, 1), "/");
});
done();
});
checker.init(
{
start: path.join(__dirname, '../'),
relativeLicensePath: true,
},
function(err, filtered) {
Object.keys(filtered)
.map(function(key) {
return filtered[key];
})
.filter(function(dep) {
return dep.licenseFile !== undefined;
})
.forEach(function(dep) {
assert.notEqual(dep.licenseFile.substr(0, 1), '/');
});
done();
}
);
});
});
describe('handle copytight statement', function(){
describe('handle copytight statement', function() {
it('should output copyright statements when configured in custom format', function(done) {
checker.init({
start: path.join(__dirname, '../'),
customFormat: {
copyright: '', // specify custom format
email: false,
licenseFile: false,
licenseText: false,
publisher: false
checker.init(
{
start: path.join(__dirname, '../'),
customFormat: {
copyright: '', // specify custom format
email: false,
licenseFile: false,
licenseText: false,
publisher: false,
},
},
function(err, output) {
assert(output['abbrev@1.0.9'] !== undefined, 'Check if the expected package still exists.');
assert.equal(output['abbrev@1.0.9'].copyright, 'Copyright (c) Isaac Z. Schlueter and Contributors');
done();
}
}, function(err, output) {
assert(output['abbrev@1.0.9'] !== undefined, 'Check if the expected package still exists.');
assert.equal(output['abbrev@1.0.9'].copyright, 'Copyright (c) Isaac Z. Schlueter and Contributors');
done();
});
);
});
});

@@ -600,9 +679,12 @@

before(function(done) {
checker.init({
start: path.join(__dirname, '../'),
onlyunknown: true
}, function(err, sorted) {
output = sorted;
done();
});
checker.init(
{
start: path.join(__dirname, '../'),
onlyunknown: true,
},
function(err, sorted) {
output = sorted;
done();
}
);
});

@@ -625,12 +707,50 @@

function parseAndInclude(parsePath, licenses, result) {
return function(done) {
checker.init(
{
start: path.join(__dirname, parsePath),
includeLicenses: licenses,
},
function(err, filtered) {
result.output = filtered;
done();
}
);
};
}
describe('should list given packages', function() {
var result = {};
before(parseAndInclude('./fixtures/includeBSD', 'BSD', result));
it('should include only Apache', function() {
var output = result.output;
assert.ok(Object.keys(output).length === 1);
});
});
describe('should not list not given packages', function() {
var result = {};
before(parseAndInclude('./fixtures/includeApache', 'BSD', result));
it('should not include Apache', function() {
var output = result.output;
assert.ok(Object.keys(output).length === 0);
});
});
describe('should only list UNKNOWN or guessed licenses with errors (argument missing)', function() {
var output;
before(function(done) {
checker.init({
start: path.join(__dirname, '../'),
production: true
}, function(err, sorted) {
output = sorted;
done();
});
checker.init(
{
start: path.join(__dirname, '../'),
production: true,
},
function(err, sorted) {
output = sorted;
done();
}
);
});

@@ -654,3 +774,2 @@

describe('should export', function() {
it('print a tree', function() {

@@ -666,3 +785,3 @@ var log = console.log;

it('a tree', function() {
it('as tree', function() {
var data = checker.asTree([{}]);

@@ -677,4 +796,4 @@ assert.ok(data);

licenses: 'MIT',
repository: '/path/to/foo'
}
repository: '/path/to/foo',
},
});

@@ -687,4 +806,3 @@ assert.ok(data);

var data = checker.asCSV({
foo: {
}
foo: {},
});

@@ -699,4 +817,4 @@ assert.ok(data);

licenses: 'MIT',
repository: '/path/to/foo'
}
repository: '/path/to/foo',
},
});

@@ -711,4 +829,4 @@ assert.ok(data);

licenses: 'MIT',
repository: '/path/to/foo'
}
repository: '/path/to/foo',
},
});

@@ -722,12 +840,15 @@ assert.ok(data);

files;
checker.asFiles({
foo: {
licenses: 'MIT',
repository: '/path/to/foo',
licenseFile: path.join(__dirname, '../LICENSE')
checker.asFiles(
{
foo: {
licenses: 'MIT',
repository: '/path/to/foo',
licenseFile: path.join(__dirname, '../LICENSE'),
},
bar: {
licenses: 'MIT',
},
},
bar: {
licenses: 'MIT'
}
}, out);
out
);

@@ -738,7 +859,5 @@ files = fs.readdirSync(out);

});
});
describe('json parsing', function() {
it('should parse json successfully (File exists + was json)', function() {

@@ -769,5 +888,3 @@ var path = './tests/config/custom_format_correct.json';

});
});
});

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc