We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 8c5ca2f commit 9cdcf3aCopy full SHA for 9cdcf3a
lib/utils/ansi-trim.js
@@ -1,7 +1,3 @@
1
-function ansiTrim (str) {
2
- var r = new RegExp('\x1b(?:\\[(?:\\d+[ABCDEFGJKSTm]|\\d+;\\d+[Hfm]|' +
3
- '\\d+;\\d+;\\d+m|6n|s|u|\\?25[lh])|\\w)', 'g')
4
- return str.replace(r, '')
5
-}
6
-
7
-module.exports = ansiTrim
+const r = new RegExp('\x1b(?:\\[(?:\\d+[ABCDEFGJKSTm]|\\d+;\\d+[Hfm]|' +
+ '\\d+;\\d+;\\d+m|6n|s|u|\\?25[lh])|\\w)', 'g')
+module.exports = str => str.replace(r, '')
test/lib/utils/ansi-trim.js
@@ -0,0 +1,5 @@
+const t = require('tap')
+const ansiTrim = require('../../../lib/utils/ansi-trim.js')
+const chalk = require('chalk')
+t.equal(ansiTrim('foo'), 'foo', 'does nothing if no ansis')
+t.equal(ansiTrim(chalk.red('foo')), 'foo', 'strips out ansis')
0 commit comments