Comparing version 0.0.2 to 0.0.3
@@ -7,2 +7,10 @@ 'use strict'; | ||
/** | ||
* The name of this parser. | ||
* | ||
* @type {String} | ||
* @private | ||
*/ | ||
name: 'content', | ||
/** | ||
* Parse the markdown information from the package. | ||
@@ -9,0 +17,0 @@ * |
@@ -14,2 +14,10 @@ 'use strict'; | ||
/** | ||
* The name of this parser. | ||
* | ||
* @type {String} | ||
* @private | ||
*/ | ||
name: 'github', | ||
/** | ||
* All the filenames that we're interested in from Github that can potentially | ||
@@ -24,6 +32,4 @@ * contain the license information. | ||
filenames: [ | ||
'LICENSE', // Uppercase version. | ||
'license', // Lowercase variant for people who don't follow the "rules" | ||
'README', | ||
'readme' | ||
'license', | ||
'readme', | ||
].concat([ | ||
@@ -33,4 +39,3 @@ 'markdown', 'mdown', 'md', 'textile', 'rdoc', 'org', 'creole', 'mediawiki', | ||
].reduce(function flatten(slim, extension) { | ||
slim.push('LICENSE.'+ extension, 'license.'+ extension); | ||
slim.push('README.'+ extension, 'readme.'+ extension); | ||
slim.push('license.'+ extension, 'readme.'+ extension); | ||
return slim; | ||
@@ -90,3 +95,3 @@ }, [])), | ||
}, function done(err) { | ||
next(err, parser.normalize(license)); | ||
next(err, license); | ||
}); | ||
@@ -148,3 +153,3 @@ }); | ||
debug('retreiving file list from %s', url); | ||
debug('retrieving file list from %s', url); | ||
@@ -166,3 +171,3 @@ this.request({ | ||
files = files.filter(function filter(file) { | ||
return !!~parser.filenames.indexOf(file.name) && file.size > 0; | ||
return !!~parser.filenames.indexOf(file.name.toLowerCase()) && file.size > 0; | ||
}); | ||
@@ -169,0 +174,0 @@ |
@@ -71,7 +71,7 @@ 'use strict'; | ||
var parser, result; | ||
var parser, result, name; | ||
async.doWhilst(function does(next) { | ||
var name = options.order.shift() | ||
, parser = parse.parsers[name]; | ||
name = options.order.shift(); | ||
parser = parse.parsers[name]; | ||
@@ -93,3 +93,3 @@ if (!parser.supported(data)) return next(); | ||
}, function done(err) { | ||
next(err, result); | ||
next(err, result, name); | ||
}); | ||
@@ -96,0 +96,0 @@ } |
17
npm.js
@@ -13,2 +13,10 @@ 'use strict'; | ||
/** | ||
* The name of this parser. | ||
* | ||
* @type {String} | ||
* @private | ||
*/ | ||
name: 'npm', | ||
/** | ||
* Parse the npm license information from the package. | ||
@@ -85,11 +93,6 @@ * | ||
); | ||
} | ||
if ('object' === typeof data.licenses && Object.keys(data.licenses).length) { | ||
} else if ('object' === typeof data.licenses) { | ||
Array.prototype.push.apply( | ||
matches, | ||
Object.keys(data.licenses).map(function map(key) { | ||
if (!parser.license(data.licenses[key])) return undefined; | ||
return data.licenses[key]; | ||
}).filter(Boolean) | ||
parser.license(data) | ||
); | ||
@@ -96,0 +99,0 @@ } |
{ | ||
"name": "licenses", | ||
"version": "0.0.2", | ||
"version": "0.0.3", | ||
"description": "A small tool that detects licensing information for a given Node.js module", | ||
@@ -24,4 +24,5 @@ "main": "index.js", | ||
"chai": "1.9.x", | ||
"pre-commit": "0.0.x" | ||
"pre-commit": "0.0.x", | ||
"argh": "~0.1.1" | ||
} | ||
} |
@@ -142,3 +142,3 @@ 'use strict'; | ||
licenses, | ||
license.split(/\s{0,}(?:\/|and|or|,)\s{0,}/g) | ||
license.split(/\s{0,}(?:\/|\sand\s|\sor\s|,)\s{0,}/g) | ||
); | ||
@@ -154,2 +154,8 @@ | ||
/** | ||
* Tokenizer for the license files so we can figure how much lines of text from | ||
* the given license matches against a string. | ||
* | ||
* @param {String} str The content that needs to get tokenized. | ||
* @param {Number} amount The amount of words we should combine. | ||
* @api private | ||
*/ | ||
@@ -156,0 +162,0 @@ Parser.readable('tokenizer', function tokenizer(str, amount) { |
@@ -45,3 +45,8 @@ describe('Parser', function () { | ||
}); | ||
it('requires spaces the and or keywords', function () { | ||
expect(parser.dual(['MITandGPL']).join(':')).to.equal('MITandGPL'); | ||
expect(parser.dual(['MITorGPL']).join(':')).to.equal('MITorGPL'); | ||
}); | ||
}); | ||
}); |
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
1171123
40
4397
4
4
1