Suggested String Template Example

Here's a pattern I've been using lately.
This commit is contained in:
Dan Levy 2017-12-24 21:49:13 -07:00 committed by GitHub
parent a8c60e37fa
commit 8ecbe9bcd5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -83,6 +83,10 @@ RAM: {green ${ram.used / ram.total * 100}%}
DISK: {rgb(255,131,0) ${disk.used / disk.total * 100}%}
`);
// ES2015 single-color tagged template literal
const {yellow, red} = require('chalk');
log(yellow`CPU:`, red`${cpu.totalPercent}`);
// Use RGB colors in terminal emulators that support it.
log(chalk.keyword('orange')('Yay for orange colored text!'));
log(chalk.rgb(123, 45, 67).underline('Underlined reddish color'));