Skip to content

Commit

Permalink
mungePackage now pulls out author name.
Browse files Browse the repository at this point in the history
  • Loading branch information
bcoe committed Oct 6, 2013
1 parent 1ae4611 commit 4dda109
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
4 changes: 3 additions & 1 deletion lib/check-npm.js
Expand Up @@ -99,9 +99,11 @@ exports.CheckNPM.prototype.getNewPackages = function(rawPackages, callback) {

exports.CheckNPM.prototype.mungePackage = function(rawPackage) {

var distTags = rawPackage['dist-tags'] || {};
var distTags = rawPackage['dist-tags'] || {},
author = rawPackage.author || {};

return {
author: author.name ? author.name : '',
version: distTags.latest || false,
description: rawPackage.description || '',
name: rawPackage.name,
Expand Down
25 changes: 24 additions & 1 deletion test/test-check-npm.js
Expand Up @@ -62,10 +62,12 @@ describe('CheckNPM', function() {
'latest': '0.0.1'
},
name: 'foolib',
description: 'awesome'
description: 'awesome',
author: {name: 'ben'}
},
mungedPackage = checkNPM.mungePackage(rawPackage);

equal('ben', mungedPackage.author);
equal('foolib', mungedPackage.name);
equal('awesome', mungedPackage.description);
equal('0.0.1', mungedPackage.version);
Expand All @@ -84,6 +86,27 @@ describe('CheckNPM', function() {
equal(false, mungedPackage.version);
equal('https://npmjs.org/package/foolib', mungedPackage.url);
});

it('should handle missing author key', function() {
var checkNPM = new CheckNPM(),
rawPackage = {
name: 'foolib'
},
mungedPackage = checkNPM.mungePackage(rawPackage);

equal('', mungedPackage.author);
});

it('should handle missing author.name', function() {
var checkNPM = new CheckNPM(),
rawPackage = {
name: 'foolib',
author: {email: 'bencoe@gmail.com'}
},
mungedPackage = checkNPM.mungePackage(rawPackage);

equal('', mungedPackage.author);
});
});

describe('#majorRelease', function() {
Expand Down

0 comments on commit 4dda109

Please sign in to comment.