expand-pkg
Advanced tools
Comparing version 0.1.4 to 0.1.5
'use strict'; | ||
var utils = require('../utils'); | ||
var cache = {}; | ||
var parsed; | ||
@@ -10,12 +12,9 @@ module.exports = function(val, key, config, schema) { | ||
if (!utils.isObject(val)) { | ||
if (!parsed && !utils.isObject(val)) { | ||
var git = utils.parseGitConfig.sync(val); | ||
var obj = utils.parseGitConfig.keys(git); | ||
var remote = utils.get(obj, 'remote.origin'); | ||
if (remote) { | ||
val = config[key] = { remote: remote }; | ||
} | ||
git = utils.merge({}, git, obj); | ||
val = parsed = config[key] = git; | ||
} | ||
return val; | ||
return parsed || val; | ||
}; |
@@ -16,3 +16,5 @@ 'use strict'; | ||
return config.owner || config.username; | ||
return config.owner | ||
|| config.username | ||
|| config.author && config.author.username; | ||
}; |
'use strict'; | ||
var utils = require('../utils'); | ||
var cache = {}; | ||
var cache = {}; | ||
@@ -14,3 +16,5 @@ /** | ||
module.exports = function person(val, key, config, schema) { | ||
module.exports = function(val, key, config, schema) { | ||
if (typeof val === 'undefined') return; | ||
if (Array.isArray(val)) { | ||
@@ -20,14 +24,38 @@ var arr = []; | ||
if (typeof person === 'string') { | ||
person = utils.parseAuthor(person); | ||
person = cache[person] || (cache[person] = toAuthor(person)); | ||
} | ||
arr.push(utils.omitEmpty(person)); | ||
arr.push(person); | ||
}); | ||
val = val.length > 1 ? arr : val[0]; | ||
if (arr.length === 1) { | ||
val = arr[0]; | ||
} else { | ||
val = arr; | ||
} | ||
} | ||
if (typeof val === 'string') { | ||
val = utils.omitEmpty(utils.parseAuthor(val)); | ||
val = cache[val] || (cache[val] = toAuthor(val)); | ||
} | ||
if (utils.isObject(val)) { | ||
username(val); | ||
} | ||
return val; | ||
}; | ||
function toAuthor(val) { | ||
var author = utils.omitEmpty(utils.parseAuthor(val)); | ||
username(author); | ||
return author; | ||
} | ||
// this is obviousy a very naive check, but I'd rather keep this | ||
// simple since this can be overridden anyway | ||
function username(author) { | ||
if (utils.isObject(author) && !author.username && author.url) { | ||
if (/(github|twitter)\.com/.test(author.url)) { | ||
author.username = author.url.split('/').pop(); | ||
} | ||
} | ||
} |
@@ -20,6 +20,6 @@ 'use strict'; | ||
.field('author', ['object', 'string'], { normalize: expanders.person }) | ||
.field('authors', ['array', 'object'], { normalize: expanders.person }) | ||
.field('maintainers', 'array', { normalize: expanders.person }) | ||
.field('contributors', 'array', { normalize: expanders.person }) | ||
.field('collaborators', 'array', { normalize: expanders.person }) | ||
.field('authors', 'array', { normalize: expanders.persons }) | ||
.field('maintainers', 'array', { normalize: expanders.persons }) | ||
.field('contributors', 'array', { normalize: expanders.persons }) | ||
.field('collaborators', 'array', { normalize: expanders.persons }) | ||
@@ -26,0 +26,0 @@ /** |
{ | ||
"name": "expand-pkg", | ||
"description": "Parse string values in package.json into objects.", | ||
"version": "0.1.4", | ||
"version": "0.1.5", | ||
"homepage": "https://github.com/jonschlinkert/expand-pkg", | ||
@@ -40,2 +40,3 @@ "author": "Jon Schlinkert (https://github.com/jonschlinkert)", | ||
"delete": "^0.3.0", | ||
"fs-exists-sync": "^0.1.0", | ||
"gitty": "^3.3.4", | ||
@@ -42,0 +43,0 @@ "gulp": "^3.9.1", |
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
11418
11
285
10