0c285d3c60fe79799d5f0b4c2940c7ef14fb343c.svn-base
968 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _wrapAnsi = _interopRequireDefault(require("wrap-ansi"));
var _cliTruncate = _interopRequireDefault(require("cli-truncate"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var _default = (text, maxWidth, {
textWrap
} = {}) => {
if (textWrap === 'wrap') {
return (0, _wrapAnsi.default)(text, maxWidth, {
trim: false,
hard: true
});
}
if (String(textWrap).startsWith('truncate')) {
let position;
if (textWrap === 'truncate' || textWrap === 'truncate-end') {
position = 'end';
}
if (textWrap === 'truncate-middle') {
position = 'middle';
}
if (textWrap === 'truncate-start') {
position = 'start';
}
return (0, _cliTruncate.default)(text, maxWidth, {
position
});
}
return text;
};
exports.default = _default;