getWatermarks.js 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. 'use strict';
  2. Object.defineProperty(exports, '__esModule', {
  3. value: true
  4. });
  5. exports.default = getWatermarks;
  6. function _istanbulLibReport() {
  7. const data = _interopRequireDefault(require('istanbul-lib-report'));
  8. _istanbulLibReport = function () {
  9. return data;
  10. };
  11. return data;
  12. }
  13. function _interopRequireDefault(obj) {
  14. return obj && obj.__esModule ? obj : {default: obj};
  15. }
  16. /**
  17. * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
  18. *
  19. * This source code is licensed under the MIT license found in the
  20. * LICENSE file in the root directory of this source tree.
  21. */
  22. function getWatermarks(config) {
  23. const defaultWatermarks = _istanbulLibReport().default.getDefaultWatermarks();
  24. const {coverageThreshold} = config;
  25. if (!coverageThreshold || !coverageThreshold.global) {
  26. return defaultWatermarks;
  27. }
  28. const keys = ['branches', 'functions', 'lines', 'statements'];
  29. return keys.reduce((watermarks, key) => {
  30. const value = coverageThreshold.global[key];
  31. if (value !== undefined) {
  32. watermarks[key][1] = value;
  33. }
  34. return watermarks;
  35. }, defaultWatermarks);
  36. }