1 module.exports = normalize
3 var fixer = require("./fixer")
4 normalize.fixer = fixer
6 var makeWarning = require("./make_warning")
8 var fieldsToFix = ['name','version','description','repository','modules','scripts'
9 ,'files','bin','man','bugs','keywords','readme','homepage','license']
10 var otherThingsToFix = ['dependencies','people', 'typos']
12 var thingsToFix = fieldsToFix.map(function(fieldName) {
13 return ucFirst(fieldName) + "Field"
15 // two ways to do this in CoffeeScript on only one line, sub-70 chars:
16 // thingsToFix = fieldsToFix.map (name) -> ucFirst(name) + "Field"
17 // thingsToFix = (ucFirst(name) + "Field" for name in fieldsToFix)
18 thingsToFix = thingsToFix.concat(otherThingsToFix)
20 function normalize (data, warn, strict) {
21 if(warn === true) warn = null, strict = true
22 if(!strict) strict = false
23 if(!warn || data.private) warn = function(msg) { /* noop */ }
26 data.scripts.install === "node-gyp rebuild" &&
27 !data.scripts.preinstall) {
30 fixer.warn = function() { warn(makeWarning.apply(null, arguments)) }
31 thingsToFix.forEach(function(thingName) {
32 fixer["fix" + ucFirst(thingName)](data, strict)
34 data._id = data.name + "@" + data.version
37 function ucFirst (string) {
38 return string.charAt(0).toUpperCase() + string.slice(1);