use index.js
This commit is contained in:
parent
342686202d
commit
d2a1052042
2 changed files with 1 additions and 2 deletions
63
chalk.js
63
chalk.js
|
|
@ -1,63 +0,0 @@
|
|||
'use strict';
|
||||
var ansi = require('ansi-styles');
|
||||
var stripAnsi = require('strip-ansi');
|
||||
var hasColor = require('has-color');
|
||||
var defineProps = Object.defineProperties;
|
||||
var chalk = module.exports;
|
||||
|
||||
var styles = (function () {
|
||||
var ret = {};
|
||||
|
||||
ansi.grey = ansi.gray;
|
||||
|
||||
Object.keys(ansi).forEach(function (key) {
|
||||
ret[key] = {
|
||||
get: function () {
|
||||
this._styles.push(key);
|
||||
return this;
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
return ret;
|
||||
})();
|
||||
|
||||
function init() {
|
||||
var ret = {};
|
||||
|
||||
Object.keys(styles).forEach(function (name) {
|
||||
ret[name] = {
|
||||
get: function () {
|
||||
var obj = defineProps(function self() {
|
||||
var str = [].slice.call(arguments).join(' ');
|
||||
|
||||
if (!chalk.enabled) {
|
||||
return str;
|
||||
}
|
||||
|
||||
return self._styles.reduce(function (str, name) {
|
||||
var code = ansi[name];
|
||||
return str ? code.open + str + code.close : '';
|
||||
}, str);
|
||||
}, styles);
|
||||
|
||||
obj._styles = [];
|
||||
|
||||
return obj[name];
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
defineProps(chalk, init());
|
||||
|
||||
chalk.styles = ansi;
|
||||
chalk.stripColor = stripAnsi;
|
||||
chalk.supportsColor = hasColor;
|
||||
|
||||
// detect mode if not set manually
|
||||
if (chalk.enabled === undefined) {
|
||||
chalk.enabled = chalk.supportsColor;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue