説明なし

comment.js 892B

12345678910111213141516171819202122232425262728293031323334
  1. /*
  2. * grunt-contrib-concat
  3. * http://gruntjs.com/
  4. *
  5. * Copyright (c) 2013 "Cowboy" Ben Alman, contributors
  6. * Licensed under the MIT license.
  7. */
  8. 'use strict';
  9. exports.init = function(/*grunt*/) {
  10. var exports = {};
  11. // Return the given source code with any leading banner comment stripped.
  12. exports.stripBanner = function(src, options) {
  13. if (!options) { options = {}; }
  14. var m = [];
  15. if (options.line) {
  16. // Strip // ... leading banners.
  17. m.push('(?:.*\\/\\/.*\\r?\\n)+\\s*');
  18. }
  19. if (options.block) {
  20. // Strips all /* ... */ block comment banners.
  21. m.push('\\/\\*[\\s\\S]*?\\*\\/');
  22. } else {
  23. // Strips only /* ... */ block comment banners, excluding /*! ... */.
  24. m.push('\\/\\*[^!][\\s\\S]*?\\*\\/');
  25. }
  26. var re = new RegExp('^\\s*(?:' + m.join('|') + ')\\s*', '');
  27. return src.replace(re, '');
  28. };
  29. return exports;
  30. };