1 | 'use strict';
|
2 |
|
3 | Object.defineProperty(exports, '__esModule', {
|
4 | value: true
|
5 | });
|
6 | exports.normalizeDiffOptions = exports.noColor = void 0;
|
7 |
|
8 | var _chalk = _interopRequireDefault(require('chalk'));
|
9 |
|
10 | function _interopRequireDefault(obj) {
|
11 | return obj && obj.__esModule ? obj : {default: obj};
|
12 | }
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 | const noColor = string => string;
|
21 |
|
22 | exports.noColor = noColor;
|
23 | const DIFF_CONTEXT_DEFAULT = 5;
|
24 | const OPTIONS_DEFAULT = {
|
25 | aAnnotation: 'Expected',
|
26 | aColor: _chalk.default.green,
|
27 | aIndicator: '-',
|
28 | bAnnotation: 'Received',
|
29 | bColor: _chalk.default.red,
|
30 | bIndicator: '+',
|
31 | changeColor: _chalk.default.inverse,
|
32 | changeLineTrailingSpaceColor: noColor,
|
33 | commonColor: _chalk.default.dim,
|
34 | commonIndicator: ' ',
|
35 | commonLineTrailingSpaceColor: noColor,
|
36 | contextLines: DIFF_CONTEXT_DEFAULT,
|
37 | emptyFirstOrLastLinePlaceholder: '',
|
38 | expand: true,
|
39 | includeChangeCounts: false,
|
40 | omitAnnotationLines: false,
|
41 | patchColor: _chalk.default.yellow
|
42 | };
|
43 |
|
44 | const getContextLines = contextLines =>
|
45 | typeof contextLines === 'number' &&
|
46 | Number.isSafeInteger(contextLines) &&
|
47 | contextLines >= 0
|
48 | ? contextLines
|
49 | : DIFF_CONTEXT_DEFAULT;
|
50 |
|
51 | const normalizeDiffOptions = (options = {}) => ({
|
52 | ...OPTIONS_DEFAULT,
|
53 | ...options,
|
54 | contextLines: getContextLines(options.contextLines)
|
55 | });
|
56 |
|
57 | exports.normalizeDiffOptions = normalizeDiffOptions;
|