"Fossies" - the Fresh Open Source Software Archive

Member "Atom/resources/app/apm/node_modules/normalize-package-data/lib/normalize.js" (11 Apr 2017, 1344 Bytes) of package /windows/misc/atom-windows.zip:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Javascript source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 module.exports = normalize
    2 
    3 var fixer = require("./fixer")
    4 normalize.fixer = fixer
    5 
    6 var makeWarning = require("./make_warning")
    7 
    8 var fieldsToFix = ['name','version','description','repository','modules','scripts'
    9                   ,'files','bin','man','bugs','keywords','readme','homepage','license']
   10 var otherThingsToFix = ['dependencies','people', 'typos']
   11 
   12 var thingsToFix = fieldsToFix.map(function(fieldName) { 
   13   return ucFirst(fieldName) + "Field"
   14 })
   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)
   19 
   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 */ }
   24 
   25   if (data.scripts && 
   26       data.scripts.install === "node-gyp rebuild" && 
   27       !data.scripts.preinstall) {
   28     data.gypfile = true
   29   }
   30   fixer.warn = function() { warn(makeWarning.apply(null, arguments)) }
   31   thingsToFix.forEach(function(thingName) {
   32     fixer["fix" + ucFirst(thingName)](data, strict)
   33   })
   34   data._id = data.name + "@" + data.version
   35 }
   36 
   37 function ucFirst (string) {
   38   return string.charAt(0).toUpperCase() + string.slice(1);
   39 }