Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Socket
Sign inDemoInstall

license-checker

Package Overview
Dependencies
Maintainers
1
Versions
74
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

license-checker - npm Package Compare versions

Comparing version 0.0.5 to 0.0.6

26

lib/index.js

@@ -10,2 +10,4 @@

var data = {};
var fs = require('fs');
var path = require('path');
var read = require('read-installed');

@@ -17,9 +19,8 @@ var treeify = require('treeify');

var moduleInfo = {licenses: UNKNOWN},
licenseData;
licenseData, files;
data[json.name + '@' + json.version] = moduleInfo;
if (json.repository) {
if (typeof json.repository === 'object') {
if (typeof json.repository === 'object' && typeof json.repository.url === 'string') {
moduleInfo.repository = json.repository.url.replace('git://github.com', 'https://github.com').replace('.git', '');

@@ -49,5 +50,20 @@ }

}
} else if (json.readme){
moduleInfo.licenses = license(json.readme) || UNKNOWN;
} else if (license(json.readme)) {
moduleInfo.licenses = license(json.readme);
} else {
files = fs.readdirSync(json.path).filter(function(filename) {
return filename.indexOf('LICENSE') > -1;
});
files.forEach(function(filename) {
moduleInfo.licenses = license(fs.readFileSync(path.join(json.path, filename), {encoding: 'utf8'}));
});
}
if (Array.isArray(moduleInfo.licenses)) {
if (moduleInfo.licenses.length === 1) {
moduleInfo.licenses = moduleInfo.licenses[0];
}
}
if (json.dependencies) {

@@ -54,0 +70,0 @@ Object.keys(json.dependencies).forEach(function(name) {

@@ -0,3 +1,23 @@

var MIT_LICENSE = ["Permission is hereby granted, free of charge, to any person obtaining",
"a copy of this software and associated documentation files (the",
"'Software'), to deal in the Software without restriction, including",
"without limitation the rights to use, copy, modify, merge, publish,",
"distribute, sublicense, and/or sell copies of the Software, and to",
"permit persons to whom the Software is furnished to do so, subject to",
"the following conditions:",
"",
"The above copyright notice and this permission notice shall be",
"included in all copies or substantial portions of the Software.",
"",
"THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,",
"EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF",
"MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.",
"IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY",
"CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,",
"TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE",
"SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE."].join('\n');
module.exports = function(str) {
if (str.indexOf('MIT') > -1) {
if (str.indexOf('MIT') > -1 || str.indexOf(MIT_LICENSE) > -1) {
return 'MIT*';

@@ -8,3 +28,3 @@ } else if (str.indexOf('BSD') > -1) {

return 'Apache*';
} else if (str.indexOf('DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE') > -1) {
} else if (str.indexOf('DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE') > -1 || str.indexOf('WTFPL') > -1) {
return 'WTF*';

@@ -11,0 +31,0 @@ }

83

package.json
{
"name": "license-checker",
"description": "Check license info for a pacakge",
"author": "Dav Glass <davglass@gmail.com>",
"version": "0.0.5",
"dependencies": {
"mkdirp": "*",
"treeify": "*",
"nopt": "*",
"read-installed": "*"
},
"devDependencies": {
"yui-lint": "~0.1.1",
"jshint": "~1.1.0",
"vows": "*",
"istanbul": "*"
},
"keywords": [
"license", "cli", "checker", "oss"
],
"main": "./lib/index.js",
"bin": {
"license-checker": "./bin/license-checker"
},
"scripts": {
"pretest": "jshint --config ./node_modules/yui-lint/jshint.json ./lib/",
"test": "istanbul cover --print both vows -- --spec ./tests/*.js"
},
"preferGlobal": "true",
"bugs": { "url" : "http://github.com/davglass/license-checker/issues" },
"licenses":[
{
"type" : "BSD",
"url" : "https://github.com/davglass/license-checker/blob/master/LICENSE"
}
],
"repository": {
"type":"git",
"url":"http://github.com/davglass/license-checker.git"
"name": "license-checker",
"description": "Check license info for a pacakge",
"author": "Dav Glass <davglass@gmail.com>",
"version": "0.0.6",
"dependencies": {
"mkdirp": "^0.3.5",
"treeify": "^1.0.1",
"nopt": "^2.2.0",
"read-installed": "^1.0.0"
},
"devDependencies": {
"yui-lint": "~0.1.1",
"jshint": "~1.1.0",
"vows": "*",
"istanbul": "*",
"request": "^2.34.0",
"queue": "^1.0.0"
},
"keywords": [
"license",
"cli",
"checker",
"oss"
],
"main": "./lib/index.js",
"bin": {
"license-checker": "./bin/license-checker"
},
"scripts": {
"pretest": "jshint --config ./node_modules/yui-lint/jshint.json ./lib/",
"test": "istanbul cover --print both vows -- --spec ./tests/*.js"
},
"preferGlobal": "true",
"bugs": {
"url": "http://github.com/davglass/license-checker/issues"
},
"licenses": [
{
"type": "BSD",
"url": "https://github.com/davglass/license-checker/blob/master/LICENSE"
}
],
"repository": {
"type": "git",
"url": "http://github.com/davglass/license-checker.git"
}
}

@@ -10,3 +10,3 @@ NPM License Checker

```
npm -g license-checker
npm install -g license-checker

@@ -13,0 +13,0 @@ mkdir foo

var vows = require('vows'),
assert = require('assert'),
path = require('path'),
checker = require('../lib/index');

@@ -16,2 +17,33 @@

}
},
'should parse local with unknown': {
topic: function () {
var self = this;
checker.init({
start: path.join(__dirname, '../')
}, function (sorted) {
self.callback(null, sorted);
});
},
'and give us results': function (d) {
assert.isTrue(Object.keys(d).length > 70);
assert.equal(d['abbrev@1.0.4'].licenses, 'MIT');
},
'should parse local without unknown': {
topic: function () {
var self = this;
checker.init({
start: path.join(__dirname, '../'),
unknown: true
}, function (sorted) {
self.callback(null, sorted);
});
},
'and give us results': function (d) {
assert.equal(d['vows@0.7.0'].licenses, 'BSD*');
assert.isTrue(Object.keys(d).length > 20);
}
}
}

@@ -18,0 +50,0 @@ };

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