Software zum Installieren eines Smart-Mirror Frameworks , zum Nutzen von hochschulrelevanten Informationen, auf einem Raspberry-Pi.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

normalize.js 1.3KB

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