license-checker
Advanced tools
Comparing version 5.1.1 to 5.1.2
@@ -60,2 +60,3 @@ /* | ||
} | ||
/*istanbul ignore else*/ | ||
if (parsed.color === undefined) { | ||
@@ -62,0 +63,0 @@ parsed.color = chalk.supportsColor; |
@@ -192,3 +192,3 @@ /* | ||
if (!data[item].licenses) { | ||
/*istanbul ignore else*/ | ||
/*istanbul ignore next*/ | ||
if (colorize) { | ||
@@ -244,2 +244,3 @@ data[item].licenses = chalk.bold.red(UNKNOWN); | ||
var tempItem = chalk.stripColor(item); | ||
/*istanbul ignore else*/ | ||
if (tempItem === 'undefined@undefined') { | ||
@@ -256,3 +257,2 @@ inputError = new Error('No Npm Packages Found'); | ||
/*istanbul ignore next*/ | ||
exports.print = function(sorted) { | ||
@@ -334,3 +334,2 @@ console.log(exports.asTree(sorted)); | ||
/*istanbul ignore next*/ | ||
exports.parseJson = function(jsonPath) { | ||
@@ -337,0 +336,0 @@ if (typeof jsonPath !== 'string') { |
@@ -5,3 +5,3 @@ { | ||
"author": "Dav Glass <davglass@gmail.com>", | ||
"version": "5.1.1", | ||
"version": "5.1.2", | ||
"contributors": [ | ||
@@ -34,3 +34,3 @@ "Andrew Couch <andy@couchand.com>", | ||
"nopt": "^2.2.0", | ||
"read-installed": "~3.1.3", | ||
"read-installed": "~4.0.3", | ||
"treeify": "^1.0.1" | ||
@@ -42,7 +42,7 @@ }, | ||
"git-contributors": "^0.2.3", | ||
"istanbul": "*", | ||
"istanbul": "^0.4.3", | ||
"jenkins-mocha": "^2.6.0", | ||
"jshint": "~1.1.0", | ||
"queue": "^1.0.0", | ||
"request": "^2.34.0", | ||
"vows": "0.8.0", | ||
"yui-lint": "~0.1.1" | ||
@@ -63,4 +63,4 @@ }, | ||
"pretest": "jshint --config ./node_modules/yui-lint/jshint.json ./lib/", | ||
"test": "istanbul cover --print both vows -- --spec ./tests/*.js", | ||
"posttest": "istanbul check-coverage --statements 95 --functions 100 --lines 95 --branches 90" | ||
"test": "jenkins-mocha ./tests/*.js", | ||
"posttest": "istanbul check-coverage" | ||
}, | ||
@@ -67,0 +67,0 @@ "preferGlobal": "true", |
@@ -1,25 +0,17 @@ | ||
var vows = require('vows'), | ||
assert = require('assert'), | ||
var assert = require('assert'), | ||
path = require('path'), | ||
spawn = require('child_process').spawn; | ||
var tests = { | ||
bin: { | ||
topic: function() { | ||
var test = this; | ||
spawn( | ||
'node', [path.join(__dirname, '../bin/license-checker')], { | ||
stdio: 'ignore' | ||
} | ||
).on('exit', function(code) { | ||
test.callback(code === 0); | ||
}); | ||
}, | ||
'exits with code 0': function(code) { | ||
assert.ok(code); | ||
}, | ||
} | ||
}; | ||
describe('bin/license-checker', function() { | ||
this.timeout(8000); | ||
it('should exit 0', function(done) { | ||
spawn('node', [path.join(__dirname, '../bin/license-checker')], { | ||
cwd: path.join(__dirname, '../'), | ||
stdio: 'ignore' | ||
}).on('exit', function(code) { | ||
assert.equal(code, 0); | ||
done(); | ||
}); | ||
}); | ||
vows.describe('license-checker').addBatch(tests).export(module); | ||
}); |
@@ -1,104 +0,63 @@ | ||
var vows = require('vows'), | ||
assert = require('assert'), | ||
var assert = require('assert'), | ||
license = require('../lib/license'); | ||
var tests = { | ||
loading: { | ||
topic: function() { | ||
return license; | ||
}, | ||
'should be a function': function(topic) { | ||
assert.isFunction(topic); | ||
} | ||
}, | ||
'undefined check': { | ||
topic: function() { | ||
return license(undefined); | ||
}, | ||
'should return Undefined': function(data) { | ||
assert.equal(data, 'Undefined'); | ||
} | ||
}, | ||
'MIT check': { | ||
topic: function() { | ||
return license('asdf\nasdf\nasdf\nPermission is hereby granted, free of charge, to any'); | ||
}, | ||
'should return MIT': function(data) { | ||
assert.equal(data, 'MIT*'); | ||
} | ||
}, | ||
'MIT word check': { | ||
topic: function() { | ||
return license('asdf\nasdf\nMIT\nasdf\n'); | ||
}, | ||
'should return MIT': function(data) { | ||
assert.equal(data, 'MIT*'); | ||
} | ||
}, | ||
'BSD check': { | ||
topic: function() { | ||
return license('asdf\nRedistribution and use in source and binary forms, with or without\nasdf\n'); | ||
}, | ||
'should return BSD': function(data) { | ||
assert.equal(data, 'BSD*'); | ||
} | ||
}, | ||
'BSD word check': { | ||
topic: function() { | ||
return license('asdf\nasdf\nBSD\nasdf\n'); | ||
}, | ||
'should return BSD': function(data) { | ||
assert.equal(data, 'BSD*'); | ||
} | ||
}, | ||
'Apache word check': { | ||
topic: function() { | ||
return license('asdf\nasdf\nApache License\nasdf\n'); | ||
}, | ||
'should return Apache': function(data) { | ||
assert.equal(data, 'Apache*'); | ||
} | ||
}, | ||
'WTF check': { | ||
topic: function() { | ||
return license('DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE'); | ||
}, | ||
'should return WTFPL': function(data) { | ||
assert.equal(data, 'WTFPL*'); | ||
} | ||
}, | ||
'WTF word check': { | ||
topic: function() { | ||
return license('asdf\nasdf\nWTFPL\nasdf\n'); | ||
}, | ||
'should return WTFPL': function(data) { | ||
assert.equal(data, 'WTFPL*'); | ||
} | ||
}, | ||
'ISC check': { | ||
topic: function() { | ||
return license('asdfasdf\nThe ISC License\nasdfasdf'); | ||
}, | ||
'should return ISC': function(data) { | ||
assert.equal(data, 'ISC*'); | ||
} | ||
}, | ||
'ISC word check': { | ||
topic: function() { | ||
return license('asdf\nasdf\nISC\nasdf\n'); | ||
}, | ||
'should return ISC': function(data) { | ||
assert.equal(data, 'ISC*'); | ||
} | ||
}, | ||
'Check for null': { | ||
topic: function() { | ||
return license('this is empty, hi'); | ||
}, | ||
'should return null': function(data) { | ||
assert.equal(data, null); | ||
} | ||
} | ||
}; | ||
describe('license parser', function() { | ||
vows.describe('licenses').addBatch(tests).export(module); | ||
it('should export a function', function() { | ||
assert.equal(typeof license, 'function'); | ||
}); | ||
it('undefined check', function() { | ||
assert.equal(license(undefined), 'Undefined'); | ||
}); | ||
it('MIT check', function() { | ||
var data = license('asdf\nasdf\nasdf\nPermission is hereby granted, free of charge, to any'); | ||
assert.equal(data, 'MIT*'); | ||
}); | ||
it('MIT word check', function() { | ||
var data = license('asdf\nasdf\nMIT\nasdf\n'); | ||
assert.equal(data, 'MIT*'); | ||
}); | ||
it('BSD check', function() { | ||
var data = license('asdf\nRedistribution and use in source and binary forms, with or without\nasdf\n'); | ||
assert.equal(data, 'BSD*'); | ||
}); | ||
it('BSD word check', function() { | ||
var data = license('asdf\nasdf\nBSD\nasdf\n'); | ||
assert.equal(data, 'BSD*'); | ||
}); | ||
it('Apache word check', function() { | ||
var data = license('asdf\nasdf\nApache License\nasdf\n'); | ||
assert.equal(data, 'Apache*'); | ||
}); | ||
it('WTF check', function() { | ||
var data = license('DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE'); | ||
assert.equal(data, 'WTFPL*'); | ||
}); | ||
it('WTF word check', function() { | ||
var data = license('asdf\nasdf\nWTFPL\nasdf\n'); | ||
assert.equal(data, 'WTFPL*'); | ||
}); | ||
it('ISC check', function() { | ||
var data = license('asdfasdf\nThe ISC License\nasdfasdf'); | ||
assert.equal(data, 'ISC*'); | ||
}); | ||
it('ISC word check', function() { | ||
var data = license('asdf\nasdf\nISC\nasdf\n'); | ||
assert.equal(data, 'ISC*'); | ||
}); | ||
it('Check for null', function() { | ||
var data = license('this is empty, hi'); | ||
assert.equal(data, null); | ||
}); | ||
}); |
@@ -1,3 +0,2 @@ | ||
var vows = require('vows'), | ||
assert = require('assert'), | ||
var assert = require('assert'), | ||
path = require('path'), | ||
@@ -10,41 +9,42 @@ util = require('util'), | ||
var tests = { | ||
loading: { | ||
topic: function() { | ||
return checker; | ||
}, | ||
'should load init': function(topic) { | ||
assert.isFunction(topic.init); | ||
}, | ||
'should load print': function(topic) { | ||
assert.isFunction(topic.print); | ||
} | ||
}, | ||
'should parse local with unknown': { | ||
topic: function () { | ||
var self = this; | ||
describe('main tests', function() { | ||
it('should load init', function() { | ||
assert.equal(typeof checker.init, 'function'); | ||
}); | ||
it('should load print', function() { | ||
assert.equal(typeof checker.print, 'function'); | ||
}); | ||
describe('should parse local with unknown', function(done) { | ||
var output; | ||
before(function(done) { | ||
checker.init({ | ||
start: path.join(__dirname, '../') | ||
}, function (sorted) { | ||
self.callback(null, sorted); | ||
output = sorted; | ||
done(); | ||
}); | ||
}, | ||
'and give us results': function (d) { | ||
assert.isTrue(Object.keys(d).length > 70); | ||
assert.equal(d['abbrev@1.0.7'].licenses, 'ISC'); | ||
}, | ||
'and convert to CSV': function(d) { | ||
var str = checker.asCSV(d); | ||
}); | ||
it('and give us results', function () { | ||
assert.equal(Object.keys(output).length > 70, true); | ||
assert.equal(output['abbrev@1.0.7'].licenses, 'ISC'); | ||
}); | ||
it('and convert to CSV', function() { | ||
var str = checker.asCSV(output); | ||
assert.equal('"module name","license","repository"', str.split('\n')[0]); | ||
assert.equal('"abbrev@1.0.7","ISC","https://github.com/isaacs/abbrev-js"', str.split('\n')[1]); | ||
}, | ||
'and convert to MarkDown': function(d) { | ||
var str = checker.asMarkDown(d); | ||
}); | ||
it('and convert to MarkDown', function() { | ||
var str = checker.asMarkDown(output); | ||
assert.equal('[abbrev@1.0.7](https://github.com/isaacs/abbrev-js) - ISC', str.split('\n')[0]); | ||
} | ||
}, | ||
'should parse local with unknown and custom format': { | ||
topic: function () { | ||
var self = this; | ||
}); | ||
}); | ||
describe('should parse local with unknown and custom format', function(done) { | ||
var output; | ||
before(function (done) { | ||
var format = { | ||
@@ -60,10 +60,13 @@ 'name': '<<Default Name>>', | ||
}, function (sorted) { | ||
self.callback(null, sorted); | ||
output = sorted; | ||
done(); | ||
}); | ||
}, | ||
'and give us results': function (d) { | ||
assert.isTrue(Object.keys(d).length > 70); | ||
assert.equal(d['abbrev@1.0.7'].description, 'Like ruby\'s abbrev module, but in js'); | ||
}, | ||
'and convert to CSV': function(d) { | ||
}); | ||
it('and give us results', function () { | ||
assert.ok(Object.keys(output).length > 70); | ||
assert.equal(output['abbrev@1.0.7'].description, 'Like ruby\'s abbrev module, but in js'); | ||
}); | ||
it('and convert to CSV', function() { | ||
var format = { | ||
@@ -75,7 +78,8 @@ 'name': '<<Default Name>>', | ||
var str = checker.asCSV(d, format); | ||
var str = checker.asCSV(output, format); | ||
assert.equal('"module name","name","description","pewpew"', str.split('\n')[0]); | ||
assert.equal('"abbrev@1.0.7","abbrev","Like ruby\'s abbrev module, but in js","<<Should Never be set>>"', str.split('\n')[1]); | ||
}, | ||
'and convert to MarkDown': function(d) { | ||
}); | ||
it('and convert to MarkDown', function() { | ||
var format = { | ||
@@ -87,10 +91,10 @@ 'name': '<<Default Name>>', | ||
var str = checker.asMarkDown(d, format); | ||
var str = checker.asMarkDown(output, format); | ||
assert.equal(' - **[abbrev@1.0.7](https://github.com/isaacs/abbrev-js)**', str.split('\n')[0]); | ||
} | ||
}, | ||
'should parse local without unknown': { | ||
topic: function () { | ||
var self = this; | ||
}); | ||
}); | ||
describe('should parse local without unknown', function() { | ||
var output; | ||
before(function(done) { | ||
checker.init({ | ||
@@ -100,16 +104,16 @@ start: path.join(__dirname, '../'), | ||
}, function (sorted) { | ||
self.callback(null, sorted); | ||
output = sorted; | ||
done(); | ||
}); | ||
}, | ||
'and give us results': function (d) { | ||
assert.ok(d); | ||
assert.ok(d['vows@0.8.0'], 'failed to lookup vows dep'); | ||
assert.equal(d['vows@0.8.0'].licenses, 'MIT'); | ||
assert.isTrue(Object.keys(d).length > 20); | ||
} | ||
}, | ||
'should parse local with unknown and excludes': { | ||
topic: function () { | ||
var self = this; | ||
}); | ||
it('should give us results', function () { | ||
assert.ok(output); | ||
assert.ok(Object.keys(output).length > 20); | ||
}); | ||
}); | ||
describe('should parse local with unknown and excludes', function() { | ||
var output; | ||
before(function (done) { | ||
checker.init({ | ||
@@ -119,27 +123,19 @@ start: path.join(__dirname, '../'), | ||
}, function (filtered) { | ||
self.callback(null, filtered); | ||
output = filtered; | ||
done(); | ||
}); | ||
}, | ||
'and exclude MIT and ISC licensed modules from results': function (d) { | ||
}); | ||
it('should exclude MIT and ISC licensed modules from results', function () { | ||
var excluded = true; | ||
Object.keys(d).forEach(function(item) { | ||
if (d[item].licenses && (d[item].licenses == "MIT" || d[item].licenses == "ISC")) | ||
Object.keys(output).forEach(function(item) { | ||
if (output[item].licenses && (output[item].licenses == "MIT" || output[item].licenses == "ISC")) | ||
excluded = false; | ||
}); | ||
assert.ok(excluded); | ||
} | ||
}, | ||
'should not error': { | ||
topic: function () { | ||
var lic = require('../lib/license.js'); | ||
return lic(); | ||
}, | ||
'on undefined': function (d) { | ||
assert.equal(d, 'Undefined'); | ||
} | ||
}, | ||
'should init without errors': { | ||
topic: function () { | ||
var self = this; | ||
}); | ||
}); | ||
describe('error handler', function() { | ||
it('should init without errors', function(done) { | ||
checker.init({ | ||
@@ -149,46 +145,49 @@ start: path.join(__dirname, '../'), | ||
}, function (sorted, err) { | ||
self.callback(sorted, err); | ||
assert.equal(err, null); | ||
done(); | ||
}); | ||
}, | ||
'errors should not exist': function (d, err) { | ||
assert.equal(err, null); | ||
} | ||
}, | ||
'should init with errors (npm packages not found)': { | ||
topic: function () { | ||
var self = this; | ||
}); | ||
it('should init with errors (npm packages not found)', function(done) { | ||
checker.init({ | ||
start: 'C:\\' | ||
}, function (sorted, err) { | ||
self.callback(sorted, err); | ||
assert.ok(util.isError(err)); | ||
done(); | ||
}); | ||
}, | ||
'errors should exist': function (d, err) { | ||
assert.isTrue(util.isError(err)); | ||
} | ||
}, | ||
'should parse with args': { | ||
topic: function () { | ||
var args = require('../lib/args.js'); | ||
return args; | ||
}); | ||
}); | ||
}, | ||
'on undefined': function (d) { | ||
var result = d.defaults(undefined); | ||
assert.equal(result.color, true); | ||
describe('should parse with args', function() { | ||
var args = require('../lib/args.js'); | ||
it('should handle undefined', function () { | ||
var result = args.defaults(undefined); | ||
assert.equal(result.color, chalk.supportsColor); | ||
assert.equal(result.start, path.resolve(path.join(__dirname, '../'))); | ||
}, | ||
'on color undefined': function (d) { | ||
var result = d.defaults({color: undefined, start: path.resolve(path.join(__dirname, '../'))}); | ||
}); | ||
it('should handle color undefined', function () { | ||
var result = args.defaults({color: undefined, start: path.resolve(path.join(__dirname, '../'))}); | ||
assert.equal(result.color, chalk.supportsColor); | ||
assert.equal(result.start, path.resolve(path.join(__dirname, '../'))); | ||
} | ||
}, | ||
'should create a custom format using customFormat successfully': { | ||
topic: function () { | ||
var self = this; | ||
}); | ||
['json', 'markdown', 'csv'].forEach(function(type) { | ||
it('should disable color on ' + type, function () { | ||
var def = { | ||
color: undefined, | ||
start: path.resolve(path.join(__dirname, '../')) | ||
}; | ||
def[type] = true; | ||
var result = args.defaults(def); | ||
assert.equal(result.color, false); | ||
assert.equal(result.start, path.resolve(path.join(__dirname, '../'))); | ||
}); | ||
}); | ||
}); | ||
describe('custom formats', function() { | ||
it('should create a custom format using customFormat successfully', function(done) { | ||
checker.init({ | ||
@@ -201,19 +200,14 @@ start: path.join(__dirname, '../'), | ||
} | ||
}, function (filtered) { | ||
self.callback(null, filtered); | ||
}, function (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(); | ||
}); | ||
}, | ||
'create custom format with name, description and pewpew (customFormat manipulation)': function (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>>'); | ||
}); | ||
} | ||
}, | ||
'should create a custom format using customPath': { | ||
topic: function () { | ||
var self = this; | ||
}); | ||
it('should create a custom format using customPath', function(done) { | ||
process.argv.push('--customPath'); | ||
@@ -229,47 +223,41 @@ process.argv.push('./customFormatExample.json'); | ||
checker.init(args, function (filtered) { | ||
self.callback(null, filtered); | ||
}); | ||
}, | ||
'create custom format with contents of customFormatExample': function (d) { | ||
var customFormatContent = fs.readFileSync(path.join(__dirname, './../customFormatExample.json'), 'utf8'); | ||
var customFormatContent = fs.readFileSync(path.join(__dirname, './../customFormatExample.json'), 'utf8'); | ||
assert.notEqual(customFormatContent, undefined); | ||
assert.notEqual(customFormatContent, null); | ||
assert.notEqual(customFormatContent, undefined); | ||
assert.notEqual(customFormatContent, null); | ||
var customJson = JSON.parse(customFormatContent); | ||
var customJson = JSON.parse(customFormatContent); | ||
//Test dynamically with the file directly | ||
Object.keys(d).forEach(function(licenseItem) { | ||
Object.keys(customJson).forEach(function(definedItem) { | ||
assert.notEqual(d[licenseItem][definedItem], 'undefined'); | ||
//Test dynamically with the file directly | ||
Object.keys(filtered).forEach(function(licenseItem) { | ||
Object.keys(customJson).forEach(function(definedItem) { | ||
assert.notEqual(filtered[licenseItem][definedItem], 'undefined'); | ||
}); | ||
}); | ||
done(); | ||
}); | ||
} | ||
}, | ||
'should output the location of the license files as absolute paths': { | ||
topic: function() { | ||
var self = this; | ||
}); | ||
}); | ||
describe('should output the location of the license files', function() { | ||
it('as absolute paths', function (done) { | ||
checker.init({ | ||
start: path.join(__dirname, '../') | ||
}, function (filtered) { | ||
self.callback(null, filtered); | ||
}, function (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(); | ||
}); | ||
}, | ||
'output the location of the license files as absolute paths': function (d) { | ||
Object.keys(d).map(function (key) { | ||
return d[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); | ||
}); | ||
} | ||
}, | ||
'should output the location of the license files as relative paths when using relativeLicensePath': { | ||
topic: function() { | ||
var self = this; | ||
}); | ||
it('as relative paths when using relativeLicensePath', function(done) { | ||
checker.init({ | ||
@@ -279,19 +267,17 @@ start: path.join(__dirname, '../'), | ||
}, function (filtered) { | ||
self.callback(null, 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(); | ||
}); | ||
}, | ||
'output the location of the license files as relative paths': function (d) { | ||
Object.keys(d).map(function (key) { | ||
return d[key]; | ||
}).filter(function (dep) { | ||
return dep.licenseFile !== undefined; | ||
}).forEach(function(dep) { | ||
assert.notEqual(dep.licenseFile.substr(0, 1), "/"); | ||
}); | ||
} | ||
}, | ||
'should only list UNKNOWN or guessed licenses successful': { | ||
topic: function () { | ||
var self = this; | ||
}); | ||
}); | ||
describe('should only list UNKNOWN or guessed licenses successful', function() { | ||
var output; | ||
before(function (done) { | ||
checker.init({ | ||
@@ -301,11 +287,13 @@ start: path.join(__dirname, '../'), | ||
}, function (sorted) { | ||
self.callback(null, sorted); | ||
output = sorted; | ||
done(); | ||
}); | ||
}, | ||
'so we check if there is no license with a star or UNKNOWN found': function(d) { | ||
}); | ||
it('so we check if there is no license with a star or UNKNOWN found', function() { | ||
var onlyStarsFound = true; | ||
Object.keys(d).forEach(function(item) { | ||
if (d[item].licenses && d[item].licenses.indexOf('UNKNOWN') !== -1) { | ||
Object.keys(output).forEach(function(item) { | ||
if (output[item].licenses && output[item].licenses.indexOf('UNKNOWN') !== -1) { | ||
//Okay | ||
} else if (d[item].licenses && d[item].licenses.indexOf('*') !== -1) { | ||
} else if (output[item].licenses && output[item].licenses.indexOf('*') !== -1) { | ||
//Okay | ||
@@ -316,10 +304,9 @@ } else { | ||
}); | ||
assert.ok(onlyStarsFound); | ||
} | ||
}, | ||
'should only list UNKNOWN or guessed licenses with errors (argument missing)': { | ||
topic: function () { | ||
var self = this; | ||
}); | ||
}); | ||
describe('should only list UNKNOWN or guessed licenses with errors (argument missing)', function() { | ||
var output; | ||
before(function (done) { | ||
checker.init({ | ||
@@ -329,11 +316,13 @@ start: path.join(__dirname, '../'), | ||
}, function (sorted) { | ||
self.callback(null, sorted); | ||
output = sorted; | ||
done(); | ||
}); | ||
}, | ||
'so we check if there is no license with a star or UNKNOWN found': function(d) { | ||
}); | ||
it('so we check if there is no license with a star or UNKNOWN found', function() { | ||
var onlyStarsFound = true; | ||
Object.keys(d).forEach(function(item) { | ||
if (d[item].licenses && d[item].licenses.indexOf('UNKNOWN') !== -1) { | ||
Object.keys(output).forEach(function(item) { | ||
if (output[item].licenses && output[item].licenses.indexOf('UNKNOWN') !== -1) { | ||
//Okay | ||
} else if (d[item].licenses && d[item].licenses.indexOf('*') !== -1) { | ||
} else if (output[item].licenses && output[item].licenses.indexOf('*') !== -1) { | ||
//Okay | ||
@@ -345,16 +334,25 @@ } else { | ||
assert.equal(onlyStarsFound, false); | ||
} | ||
}, | ||
'should export a tree': { | ||
topic: function() { | ||
return checker.asTree([{}]); | ||
}, | ||
'and format it': function(data) { | ||
}); | ||
}); | ||
describe('should export', function() { | ||
it('print a tree', function() { | ||
var log = console.log; | ||
console.log = function(data) { | ||
assert.ok(data); | ||
assert.ok(data.indexOf('└─') > -1); | ||
}; | ||
checker.print([{}]); | ||
console.log = log; | ||
}); | ||
it('a tree', function() { | ||
var data = checker.asTree([{}]); | ||
assert.ok(data); | ||
assert.isTrue(data.indexOf('└─') > -1); | ||
} | ||
}, | ||
'should export as csv': { | ||
topic: function() { | ||
return checker.asCSV({ | ||
assert.ok(data.indexOf('└─') > -1); | ||
}); | ||
it('as csv', function() { | ||
var data = checker.asCSV({ | ||
foo: { | ||
@@ -365,23 +363,17 @@ licenses: 'MIT', | ||
}); | ||
}, | ||
'and format it': function(data) { | ||
assert.ok(data); | ||
assert.isTrue(data.indexOf('"foo","MIT","/path/to/foo"') > -1); | ||
} | ||
}, | ||
'should export as csv with partial data': { | ||
topic: function() { | ||
return checker.asCSV({ | ||
assert.ok(data.indexOf('"foo","MIT","/path/to/foo"') > -1); | ||
}); | ||
it('as csv with partial data', function() { | ||
var data = checker.asCSV({ | ||
foo: { | ||
} | ||
}); | ||
}, | ||
'and format it': function(data) { | ||
assert.ok(data); | ||
assert.isTrue(data.indexOf('"foo","",""') > -1); | ||
} | ||
}, | ||
'should export as markdown': { | ||
topic: function() { | ||
return checker.asMarkDown({ | ||
assert.ok(data.indexOf('"foo","",""') > -1); | ||
}); | ||
it('as markdown', function() { | ||
var data = checker.asMarkDown({ | ||
foo: { | ||
@@ -392,14 +384,12 @@ licenses: 'MIT', | ||
}); | ||
}, | ||
'and format it': function(data) { | ||
assert.ok(data); | ||
assert.isTrue(data.indexOf('[foo](/path/to/foo) - MIT') > -1); | ||
} | ||
}, | ||
'should parse json successfully (File exists + was json)': { | ||
topic: function() { | ||
assert.ok(data.indexOf('[foo](/path/to/foo) - MIT') > -1); | ||
}); | ||
}); | ||
describe('json parsing', function() { | ||
it('should parse json successfully (File exists + was json)', function() { | ||
var path = './tests/config/custom_format_correct.json'; | ||
return path; | ||
}, | ||
'and check it': function(path) { | ||
var json = checker.parseJson(path); | ||
@@ -409,26 +399,23 @@ assert.notEqual(json, undefined); | ||
assert.equal(json.licenseModified, 'no'); | ||
} | ||
}, | ||
'should parse json with errors (File exists + no json)': { | ||
topic: function() { | ||
}); | ||
it('should parse json with errors (File exists + no json)', function() { | ||
var path = './tests/config/custom_format_broken.json'; | ||
return path; | ||
}, | ||
'and check it': function(path) { | ||
var json = checker.parseJson(path); | ||
assert.ok(json instanceof Error); | ||
} | ||
}, | ||
'should parse json with errors (File not found)': { | ||
topic: function() { | ||
}); | ||
it('should parse json with errors (File not found)', function() { | ||
var path = './NotExitingFile.json'; | ||
return path; | ||
}, | ||
'and check it': function(path) { | ||
var json = checker.parseJson(path); | ||
assert.ok(json instanceof Error); | ||
} | ||
}, | ||
}; | ||
}); | ||
it('should parse json with errors (null passed)', function() { | ||
var json = checker.parseJson(null); | ||
assert.ok(json instanceof Error); | ||
}); | ||
}); | ||
vows.describe('license-checker').addBatch(tests).export(module); | ||
}); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
18
43460
911
+ Addedfs.realpath@1.0.0(transitive)
+ Addedfunction-bind@1.1.2(transitive)
+ Addedglob@7.2.3(transitive)
+ Addedhasown@2.0.2(transitive)
+ Addedhosted-git-info@2.8.9(transitive)
+ Addedis-core-module@2.15.1(transitive)
+ Addedjson-parse-even-better-errors@2.3.1(transitive)
+ Addednormalize-package-data@2.5.0(transitive)
+ Addednpm-normalize-package-bin@1.0.1(transitive)
+ Addedpath-parse@1.0.7(transitive)
+ Addedread-installed@4.0.3(transitive)
+ Addedread-package-json@2.1.2(transitive)
+ Addedresolve@1.22.8(transitive)
+ Addedsemver@5.7.2(transitive)
+ Addedspdx-correct@3.2.0(transitive)
+ Addedspdx-exceptions@2.5.0(transitive)
+ Addedspdx-expression-parse@3.0.1(transitive)
+ Addedspdx-license-ids@3.0.20(transitive)
+ Addedsupports-preserve-symlinks-flag@1.0.0(transitive)
+ Addedvalidate-npm-package-license@3.0.4(transitive)
- Removedgithub-url-from-git@1.5.0(transitive)
- Removedgithub-url-from-username-repo@1.0.2(transitive)
- Removedglob@5.0.15(transitive)
- Removedgraceful-fs@3.0.12(transitive)
- Removedjju@1.4.0(transitive)
- Removedjson-parse-helpfulerror@1.0.3(transitive)
- Removednatives@1.1.6(transitive)
- Removednormalize-package-data@1.0.3(transitive)
- Removedread-installed@3.1.5(transitive)
- Removedread-package-json@1.3.3(transitive)
- Removedsemver@4.3.6(transitive)
Updatedread-installed@~4.0.3