Skip to content

Commit

Permalink
Strip ansi escape codes for getting lines lengths
Browse files Browse the repository at this point in the history
  • Loading branch information
jbcarpanelli committed Jun 16, 2019
1 parent 38e6637 commit 574a1eb
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 11 deletions.
50 changes: 41 additions & 9 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@
"license": "MIT",
"dependencies": {
"chalk": "^2.4.2",
"cli-cursor": "^3.0.0"
"cli-cursor": "^3.0.0",
"strip-ansi": "^5.2.0"
},
"devDependencies": {
"chai": "^4.2.0",
Expand Down
3 changes: 2 additions & 1 deletion utils.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
'use strict';

const readline = require('readline');
const stripAnsi = require('strip-ansi');
const { dashes, dots } = require('./spinners');

const VALID_STATUSES = ['succeed', 'fail', 'spinning', 'non-spinnable', 'stopped'];
Expand Down Expand Up @@ -60,7 +61,7 @@ function breakText(text, prefixLength) {
}

function getLinesLength(text, prefixLength) {
return text
return stripAnsi(text)
.split('\n')
.map((line, index) => index === 0 ? line.length + prefixLength : line.length);
}
Expand Down

0 comments on commit 574a1eb

Please sign in to comment.