1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | exports.wordWrap = exports.indent = exports.TTY_WIDTH = exports.stripAnsi = exports.stringWidth = exports.sliceAnsi = void 0;
|
4 | const sliceAnsi = require("slice-ansi");
|
5 | exports.sliceAnsi = sliceAnsi;
|
6 | const stringWidth = require("string-width");
|
7 | exports.stringWidth = stringWidth;
|
8 | const stripAnsi = require("strip-ansi");
|
9 | exports.stripAnsi = stripAnsi;
|
10 | const wrapAnsi = require("wrap-ansi");
|
11 | const MIN_TTY_WIDTH = 80;
|
12 | const MAX_TTY_WIDTH = 120;
|
13 | exports.TTY_WIDTH = process.stdout.columns ? Math.max(MIN_TTY_WIDTH, Math.min(process.stdout.columns, MAX_TTY_WIDTH)) : Infinity;
|
14 | function indent(n = 4) {
|
15 | return ' '.repeat(n);
|
16 | }
|
17 | exports.indent = indent;
|
18 | function wordWrap(msg, { width = exports.TTY_WIDTH, indentation = 0, append = '' }) {
|
19 | return wrapAnsi(msg, width - indentation - append.length, { trim: true }).split('\n').join(`${append}\n${indent(indentation)}`);
|
20 | }
|
21 | exports.wordWrap = wordWrap;
|