UNPKG

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