From 7c02cf45f80d9c16c1d53496b28c4caeb382a36c Mon Sep 17 00:00:00 2001 From: Josh Junon Date: Thu, 8 Sep 2016 03:12:05 -0700 Subject: [PATCH] Add log statement to chalk examples (#129) * Add log statement to chalk examples Added what are essentially `console.log()` calls to the chalk examples. Closes #128. * Update readme.md --- readme.md | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/readme.md b/readme.md index f0fbf2e..6e324be 100644 --- a/readme.md +++ b/readme.md @@ -47,36 +47,35 @@ console.log(chalk.blue('Hello world!')); Chalk comes with an easy to use composable API where you just chain and nest the styles you want. -Here without `console.log` for purity. - ```js const chalk = require('chalk'); +const log = console.log; // combine styled and normal strings -chalk.blue('Hello') + 'World' + chalk.red('!'); +log(chalk.blue('Hello') + 'World' + chalk.red('!')); // compose multiple styles using the chainable API -chalk.blue.bgRed.bold('Hello world!'); +log(chalk.blue.bgRed.bold('Hello world!')); // pass in multiple arguments -chalk.blue('Hello', 'World!', 'Foo', 'bar', 'biz', 'baz'); +log(chalk.blue('Hello', 'World!', 'Foo', 'bar', 'biz', 'baz')); // nest styles -chalk.red('Hello', chalk.underline.bgBlue('world') + '!'); +log(chalk.red('Hello', chalk.underline.bgBlue('world') + '!')); // nest styles of the same type even (color, underline, background) -chalk.green( +log(chalk.green( 'I am a green line ' + chalk.blue.underline.bold('with a blue substring') + ' that becomes green again!' -); +)); // ES2015 template literal -const systemStats = ` +log(` CPU: ${chalk.red('90%')} RAM: ${chalk.green('40%')} DISK: ${chalk.yellow('70%')} -`; +`); ``` Easily define your own themes.