UNPKG

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