From 3d01426a83ca0bf339d1d422fae29e4394b88c0a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sascha=20H=C3=BCdepohl?= Date: Sun, 24 May 2015 19:07:01 +0200 Subject: [PATCH] read config .chalkrc --- index.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/index.js b/index.js index 2bad21b..3976aa0 100644 --- a/index.js +++ b/index.js @@ -5,10 +5,20 @@ var stripAnsi = require('strip-ansi'); var hasAnsi = require('has-ansi'); var supportsColor = require('supports-color'); var defineProps = Object.defineProperties; +var fs = require('fs'); function Chalk(options) { // detect mode if not set manually 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