mirror of
https://github.com/flynx/colors.js.git
synced 2025-10-29 19:10:10 +00:00
Merge pull request #232 from ALE-Rainbow/master
Fix #180 - Custom with multi attr failure
This commit is contained in:
commit
ba56f52c62
@ -73,19 +73,17 @@ module['exports'] = function() {
|
|||||||
} else {
|
} else {
|
||||||
if (typeof(theme[prop]) === 'string') {
|
if (typeof(theme[prop]) === 'string') {
|
||||||
colors[prop] = colors[theme[prop]];
|
colors[prop] = colors[theme[prop]];
|
||||||
addProperty(prop, function() {
|
|
||||||
return colors[theme[prop]](this);
|
|
||||||
});
|
|
||||||
} else {
|
} else {
|
||||||
|
var tmp = colors[theme[prop][0]];
|
||||||
|
for (var t = 1; t < theme[prop].length; t++) {
|
||||||
|
tmp = tmp[theme[prop][t]];
|
||||||
|
}
|
||||||
|
colors[prop] = tmp;
|
||||||
|
}
|
||||||
addProperty(prop, function() {
|
addProperty(prop, function() {
|
||||||
var ret = this;
|
return colors[prop](this);
|
||||||
for (var t = 0; t < theme[prop].length; t++) {
|
|
||||||
ret = colors[theme[prop][t]](ret);
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -61,3 +61,13 @@ assert.equal(typeof ('astring'.red), 'string');
|
|||||||
assert.equal(typeof ('astring'.error), 'string');
|
assert.equal(typeof ('astring'.error), 'string');
|
||||||
|
|
||||||
assert.equal(s, 'string');
|
assert.equal(s, 'string');
|
||||||
|
|
||||||
|
colors.setTheme({custom: ['blue', 'bold', 'underline']});
|
||||||
|
assert.equal(colors.custom(s),
|
||||||
|
'\x1b[34m' + '\x1b[1m' + '\x1b[4m' + s +
|
||||||
|
'\x1b[24m' + '\x1b[22m' + '\x1b[39m' );
|
||||||
|
|
||||||
|
colors.setTheme({custom: ['red', 'italic', 'inverse']});
|
||||||
|
assert.equal(colors.custom(s),
|
||||||
|
'\x1b[31m' + '\x1b[3m' + '\x1b[7m' + s +
|
||||||
|
'\x1b[27m' + '\x1b[23m' + '\x1b[39m' );
|
||||||
@ -57,3 +57,12 @@ colors.setTheme({error: 'red'});
|
|||||||
assert.equal(typeof (colors.red('astring')), 'string');
|
assert.equal(typeof (colors.red('astring')), 'string');
|
||||||
assert.equal(typeof (colors.error('astring')), 'string');
|
assert.equal(typeof (colors.error('astring')), 'string');
|
||||||
|
|
||||||
|
colors.setTheme({custom: ['blue', 'bold', 'underline']});
|
||||||
|
assert.equal(colors.custom(s),
|
||||||
|
'\x1b[4m' + '\x1b[1m' + '\x1b[34m' + s +
|
||||||
|
'\x1b[39m' + '\x1b[22m' + '\x1b[24m' );
|
||||||
|
|
||||||
|
colors.setTheme({custom: ['red', 'italic', 'inverse']});
|
||||||
|
assert.equal(colors.custom(s),
|
||||||
|
'\x1b[7m' + '\x1b[3m' + '\x1b[31m' + s +
|
||||||
|
'\x1b[39m' + '\x1b[23m' + '\x1b[27m' );
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user