Skip to content

Instantly share code, notes, and snippets.

@chimericdream
Last active October 19, 2020 05:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chimericdream/28dabb0c0111c3c43e6553c67ac2057c to your computer and use it in GitHub Desktop.
Save chimericdream/28dabb0c0111c3c43e6553c67ac2057c to your computer and use it in GitHub Desktop.
Chalk issue with string from a file
const chalk = require('chalk');
const fs = require('fs');
const inline = chalk`{red.bold this is a test}
{green with multiple} {white.bold colors and}
{magenta lines}`;
const fromFile = fs.readFileSync('./message.txt', 'utf8');
console.log(inline);
console.log('----------------------');
console.log(chalk`${fromFile}`);
{red.bold this is a test}
{green with multiple} {white.bold colors and}
{magenta lines}
{
"name": "chalk-test",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"chalk": "^4.1.0"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment