mirror of
https://github.com/flynx/colors.js.git
synced 2025-10-28 18:40:09 +00:00
parent
2631877f88
commit
f487e8ebad
@ -2,3 +2,4 @@
|
|||||||
/tests/
|
/tests/
|
||||||
/.travis.yml
|
/.travis.yml
|
||||||
/screenshots
|
/screenshots
|
||||||
|
*.sw*
|
||||||
|
|||||||
@ -73,16 +73,22 @@ 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[prop](this);
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
var tmp = colors[theme[prop][0]];
|
var themePropApplicator = function(str) {
|
||||||
for (var t = 1; t < theme[prop].length; t++) {
|
var ret = str || this;
|
||||||
tmp = tmp[theme[prop][t]];
|
for (var t = 0; t < theme[prop].length; t++) {
|
||||||
}
|
ret = colors[theme[prop][t]](ret);
|
||||||
colors[prop] = tmp;
|
}
|
||||||
|
return ret;
|
||||||
|
};
|
||||||
|
addProperty(prop, themePropApplicator);
|
||||||
|
colors[prop] = function(str){
|
||||||
|
return themePropApplicator(str);
|
||||||
|
};
|
||||||
}
|
}
|
||||||
addProperty(prop, function() {
|
|
||||||
return colors[prop](this);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@ -64,10 +64,10 @@ assert.equal(s, 'string');
|
|||||||
|
|
||||||
colors.setTheme({custom: ['blue', 'bold', 'underline']});
|
colors.setTheme({custom: ['blue', 'bold', 'underline']});
|
||||||
assert.equal(colors.custom(s),
|
assert.equal(colors.custom(s),
|
||||||
'\x1b[34m' + '\x1b[1m' + '\x1b[4m' + s +
|
'\x1b[4m' + '\x1b[1m' + '\x1b[34m' + s +
|
||||||
'\x1b[24m' + '\x1b[22m' + '\x1b[39m' );
|
'\x1b[39m' + '\x1b[22m' + '\x1b[24m' );
|
||||||
|
|
||||||
colors.setTheme({custom: ['red', 'italic', 'inverse']});
|
colors.setTheme({custom: ['red', 'italic', 'inverse']});
|
||||||
assert.equal(colors.custom(s),
|
assert.equal(colors.custom(s),
|
||||||
'\x1b[31m' + '\x1b[3m' + '\x1b[7m' + s +
|
'\x1b[7m' + '\x1b[3m' + '\x1b[31m' + s +
|
||||||
'\x1b[27m' + '\x1b[23m' + '\x1b[39m' );
|
'\x1b[39m' + '\x1b[23m' + '\x1b[27m' );
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user