generate-banner.js 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. /*global location, define*/
  2. define(['lodash', 'package', 'lib/build-query'], function(_, pkg, buildQuery) {
  3. var domain = 'modernizr.com';
  4. if (typeof location !== 'undefined' && 'host' in location) {
  5. domain = location.host;
  6. }
  7. // Return a Modernizr file banner.
  8. // Usage:
  9. // require('banners')(type);
  10. // Arguments:
  11. // type (String, required): either 'compact' or 'full'.
  12. return function banners(type, config) {
  13. config = config || {};
  14. var query = buildQuery(config);
  15. if (!type || type === 'compact') {
  16. return '/*! ' + pkg.name + ' ' + pkg.version + ' (Custom Build) | ' + pkg.license + ' *\n' +
  17. ' * https://' + domain + '/download/' + query +
  18. ' !*/\n';
  19. }
  20. else if (type === 'full') {
  21. return '/*!\n' +
  22. ' * ' + pkg.name + ' v' + pkg.version + '\n' +
  23. ' * Build https://' + domain + '/download' + query + '\n' +
  24. ' *\n' +
  25. ' * Copyright (c)\n * ' + _.map(pkg.contributors, 'name').join('\n * ') + '\n\n' +
  26. ' * ' + pkg.license + ' License\n */\n' +
  27. '\n' +
  28. '/*\n' +
  29. ' * Modernizr tests which native CSS3 and HTML5 features are available in the\n' +
  30. ' * current UA and makes the results available to you in two ways: as properties on\n' +
  31. ' * a global `Modernizr` object, and as classes on the `<html>` element. This\n' +
  32. ' * information allows you to progressively enhance your pages with a granular level\n' +
  33. ' * of control over the experience.\n*/\n';
  34. } else {
  35. throw 'banners() must be passed "compact" or "full" as an argument.';
  36. }
  37. };
  38. });