Added wrapper support

The wrapper marks the unprintable characters from each style tag.
This is very useful when debugging or outputing it in different terminals. You can use it to identify the unprintable characters or even to escape them.

Also added tests for it.
Added a description about it to the readme dile.
wq
This commit is contained in:
Felipe 2018-02-04 15:10:22 -02:00
parent 6554030550
commit 503159805f
5 changed files with 65 additions and 3 deletions

25
test/wrapper.js Normal file
View file

@ -0,0 +1,25 @@
// Import path from 'path';
import test from 'ava';
// Import execa from 'execa';
// Spoof supports-color
require('./_supports-color')(__dirname);
const m = require('..');
m.wrapper = {
pre: '@',
post: '#'
};
test('add wrapper to underline', t => {
t.is(m.underline('foo'), '@\u001B[4m#foo@\u001B[24m#');
});
test('add wrapper to color', t => {
t.is(m.red('foo'), '@\u001B[31m#foo@\u001B[39m#');
});
test('add wrapper to bgColor', t => {
t.is(m.bgRed('foo'), '@\u001B[41m#foo@\u001B[49m#');
});