normalize-pkg
Advanced tools
Comparing version 0.2.3 to 0.2.4
@@ -32,8 +32,6 @@ 'use strict'; | ||
} | ||
if (typeof config.repository === 'string') { | ||
var parsed = utils.parseUrl(config.repository); | ||
if (parsed && parsed.repopath) { | ||
config[key] = 'https://github.com/' + parsed.repopath; | ||
return config[key]; | ||
var res = homepage(config); | ||
if (res) { | ||
return (config[key] = res); | ||
} | ||
@@ -90,7 +88,9 @@ } | ||
var repo = stripSlash(parsed.repopath); | ||
this.set('name', parsed.repo); | ||
this.set('author.username', parsed.user); | ||
this.set('repository', parsed.repopath); | ||
this.set('repository', repo); | ||
this.set('branch', parsed.branch); | ||
return parsed.repopath; | ||
return repo; | ||
} | ||
@@ -142,3 +142,3 @@ }, | ||
value: function (key, val, config) { | ||
val = arrayify(val || []); | ||
val = utils.arrayify(val || []); | ||
@@ -339,4 +339,9 @@ if (!val.length && config.main) { | ||
function arrayify(val) { | ||
return Array.isArray(val) ? val : [val]; | ||
function homepage(config) { | ||
var parsed = utils.parseUrl(config.repository); | ||
if (parsed && parsed.repopath) { | ||
var res = 'https://github.com/' + parsed.repopath; | ||
return stripSlash(res); | ||
} | ||
return null; | ||
} | ||
@@ -349,1 +354,5 @@ | ||
} | ||
function stripSlash(str) { | ||
return str.replace(/\/$/, ''); | ||
} |
@@ -51,2 +51,12 @@ 'use strict'; | ||
/** | ||
* Utils | ||
*/ | ||
utils.arrayify = function(val) { | ||
if (!val) return []; | ||
return Array.isArray(val) ? val : [val]; | ||
}; | ||
/** | ||
* Expose `utils` modules | ||
@@ -53,0 +63,0 @@ */ |
{ | ||
"name": "normalize-pkg", | ||
"description": "Normalize values in package.json to improve compatibility, programmatic readability and usefulness with third party libs.", | ||
"version": "0.2.3", | ||
"version": "0.2.4", | ||
"homepage": "https://github.com/jonschlinkert/normalize-pkg/", | ||
@@ -28,3 +28,3 @@ "author": "Jon Schlinkert (https://github.com/jonschlinkert)", | ||
"get-value": "^2.0.0", | ||
"kind-of": "^2.0.1", | ||
"kind-of": "^3.0.2", | ||
"lazy-cache": "^0.2.4", | ||
@@ -39,3 +39,3 @@ "matched": "^0.3.2", | ||
"set-value": "^0.3.1", | ||
"stringify-author": "^0.1.1" | ||
"stringify-author": "^0.1.3" | ||
}, | ||
@@ -42,0 +42,0 @@ "devDependencies": { |
18013
480
Updatedkind-of@^3.0.2
Updatedstringify-author@^0.1.3