read config .chalkrc
This commit is contained in:
parent
f41c70d719
commit
3d01426a83
1 changed files with 10 additions and 0 deletions
10
index.js
10
index.js
|
|
@ -5,10 +5,20 @@ var stripAnsi = require('strip-ansi');
|
||||||
var hasAnsi = require('has-ansi');
|
var hasAnsi = require('has-ansi');
|
||||||
var supportsColor = require('supports-color');
|
var supportsColor = require('supports-color');
|
||||||
var defineProps = Object.defineProperties;
|
var defineProps = Object.defineProperties;
|
||||||
|
var fs = require('fs');
|
||||||
|
|
||||||
function Chalk(options) {
|
function Chalk(options) {
|
||||||
// detect mode if not set manually
|
// detect mode if not set manually
|
||||||
this.enabled = !options || options.enabled === undefined ? supportsColor : options.enabled;
|
this.enabled = !options || options.enabled === undefined ? supportsColor : options.enabled;
|
||||||
|
var configPath = process.cwd() + '/.chalkrc';
|
||||||
|
if (fs.existsSync(configPath)) {
|
||||||
|
var content = JSON.parse(fs.readFileSync(configPath));
|
||||||
|
if (content.overwrite) {
|
||||||
|
Object.keys(content.overwrite).forEach(function (key) {
|
||||||
|
ansiStyles[key] = ansiStyles[content.overwrite[key]];
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// use bright blue on Windows as the normal blue color is illegible
|
// use bright blue on Windows as the normal blue color is illegible
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue