Closed fis-cz closed 6 years ago
Unable to reproduce -- this prints as expected for me:
const colors = require('colors');
console.log(`jim
bob
foo`.red);
There are several strange syntax issues in your example, such such as not putting colors in quotes in the require statement, and then appearing to log the colors variable instead of your text.
If you have a fully valid sample where things don't work, please feel free to re-open this! Thanks!
Sorry I didn't copy-paste before. I am testing in Node.js 10.2.1, colors 1.3.0 (at least this is the version mentioned in packages.json)
Copy - paste example:
let colors = require("colors");
let text = `line1
line2
line3
`;
console.log(text);
console.log(colors.red(text));
Expected outout:
line1
line2
line3
line1
line2
line3
Current output:
line1
line2
line3
line1
line2
line3
Seems like empty lines are striped.
Thanks for this snippet! Indeed, it seems there is different behavior in logging colors.red(text)
vs. text.red
-- this seems like a valid issue to me and I'll try to sort it out. Thanks!
Tested both:
let colors = require("colors");
let text = `line1
line2
line3
`;
console.log(text.red);
console.log(colors.red(text));
and the first one really works as expected.
This has been fixed in the ^above commit and will be included in the next release of colors. If this is urgent for you in the meantime, you can reference "colors": "Marak/colors.js#develop"
in your package.json
instead of a version number, to directly get the latest version from github. Thanks again for reporting!
Thanks
When I use multiline string with colors, i.e.:
the empty lines are stripped from the text so the output is:
Is this a bug or do I miss something?