chalk/wrap-ansi

Newline handling in 6.0.0 #39

unindented posted onGitHub

In wrap-ansi@5.0.0 all newlines are converted properly:

const wrapAnsi = require("wrap-ansi@5.0.0")
console.log(wrapAnsi('a\r\n\r\nb', 5)) // outputs "a\n\nb"

In wrap-ansi@6.0.0 not all newlines are converted:

const wrapAnsi = require("wrap-ansi@6.0.0")
console.log(wrapAnsi('a\r\n\r\nb', 5)) // outputs "a\r\n\nb"

In 5.1.0 I get the same result as in 6.0.0. I think the change happened in https://github.com/chalk/wrap-ansi/pull/33 which was merged after 5.0.0. I don't think we should "normalize" the newlines but rather keep them as they were inputted.

posted by kevva over 5 years ago

Fair enough. So I guess this is a "Won't fix"?

posted by unindented over 5 years ago

It needs to be addressed in some way. Currently the output it neither untouched or completely normalized. We just need to decide on how we want it to work. I'll let others chime in before submitting a PR.

posted by kevva over 5 years ago

I think it's totally fine for us to normalize newlines as long as we document the behavior. It's the wanted behavior in most cases.

posted by sindresorhus over 5 years ago

Fund this Issue

$0.00
Funded

Pull requests