Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

printInstallDetails.mjs 1.9 KiB

pirms 3 gadiem
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /*
  2. Copyright 2017 Google Inc.
  3. Licensed under the Apache License, Version 2.0 (the "License");
  4. you may not use this file except in compliance with the License.
  5. You may obtain a copy of the License at
  6. https://www.apache.org/licenses/LICENSE-2.0
  7. Unless required by applicable law or agreed to in writing, software
  8. distributed under the License is distributed on an "AS IS" BASIS,
  9. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. See the License for the specific language governing permissions and
  11. limitations under the License.
  12. */
  13. import {logger} from 'workbox-core/_private/logger.mjs';
  14. import '../_version.mjs';
  15. /**
  16. * @param {string} groupTitle
  17. * @param {Array<PrecacheEntry>} entries
  18. *
  19. * @private
  20. */
  21. const _nestedGroup = (groupTitle, entries) => {
  22. if (entries.length === 0) {
  23. return;
  24. }
  25. logger.groupCollapsed(groupTitle);
  26. entries.forEach((entry) => {
  27. logger.log(entry._originalInput);
  28. });
  29. logger.groupEnd();
  30. };
  31. /**
  32. * @param {Array<Object>} entriesToPrecache
  33. * @param {Array<Object>} alreadyPrecachedEntries
  34. *
  35. * @private
  36. * @memberof module:workbox-precachig
  37. */
  38. export default (entriesToPrecache, alreadyPrecachedEntries) => {
  39. // Goal is to print the message:
  40. // Precaching X files.
  41. // Or:
  42. // Precaching X files. Y files were cached and up-to-date.
  43. const precachedCount = entriesToPrecache.length;
  44. const alreadyPrecachedCount = alreadyPrecachedEntries.length;
  45. let printText =
  46. `Precaching ${precachedCount} file${precachedCount === 1 ? '' : 's'}.`;
  47. if (alreadyPrecachedCount > 0) {
  48. printText += ` ${alreadyPrecachedCount} ` +
  49. `file${alreadyPrecachedCount === 1 ? ' is' : 's are'} already cached.`;
  50. }
  51. logger.groupCollapsed(printText);
  52. _nestedGroup(
  53. `View precached URLs.`,
  54. entriesToPrecache);
  55. _nestedGroup(
  56. `View URLs that were already precached.`,
  57. alreadyPrecachedEntries);
  58. logger.groupEnd();
  59. };