bump jest and make tests pass

This commit is contained in:
Louis Hache committed 2020-11-13 19:11:55 +01:00
1 parent d28dc26fa3
commit 4f58d166b7
5769 files changed
+856618 -394571

No files matched your search

+9 -11
View File
@@ -21,7 +21,7 @@ const wordLengths = string => string.split(' ').map(character => stringWidth(cha
const wrapWord = (rows, word, columns) => {
const characters = [...word];
let insideEscape = false;
let isInsideEscape = false;
let visible = stringWidth(stripAnsi(rows[rows.length - 1]));
for (const [index, character] of characters.entries()) {
@@ -35,13 +35,13 @@ const wrapWord = (rows, word, columns) => {
}
if (ESCAPES.has(character)) {
insideEscape = true;
} else if (insideEscape && character === 'm') {
insideEscape = false;
isInsideEscape = true;
} else if (isInsideEscape && character === 'm') {
isInsideEscape = false;
continue;
}
if (insideEscape) {
if (isInsideEscape) {
continue;
}
@@ -80,11 +80,9 @@ const stringVisibleTrimSpacesRight = str => {
return words.slice(0, last).join(' ') + words.slice(last).join('');
};
// The wrap-ansi module can be invoked
// in either 'hard' or 'soft' wrap mode
// The wrap-ansi module can be invoked in either 'hard' or 'soft' wrap mode
//
// 'hard' will never allow a string to take up more
// than columns characters
// 'hard' will never allow a string to take up more than columns characters
//
// 'soft' allows long words to expand past the column length
const exec = (string, columns, options = {}) => {
@@ -119,8 +117,7 @@ const exec = (string, columns, options = {}) => {
}
}
// In 'hard' wrap mode, the length of a line is
// never allowed to extend past 'columns'
// In 'hard' wrap mode, the length of a line is never allowed to extend past 'columns'
if (options.hard && lengths[index] > columns) {
const remainingColumns = (columns - rowLength);
const breaksStartingThisLine = 1 + Math.floor((lengths[index] - remainingColumns - 1) / columns);
@@ -182,6 +179,7 @@ const exec = (string, columns, options = {}) => {
module.exports = (string, columns, options) => {
return String(string)
.normalize()
.replace(/\r\n/g, '\n')
.split('\n')
.map(line => exec(line, columns, options))
.join('\n');