I started trying to use nixt on a project and while I love the API, it was weirdly stripping the very first \n in my stdout/stderr strings. I did some digging around and I'm pretty sure I tracked down why.
It has to do with operator precedence inside regexes, here's an example of what is happening. You can fix it in a couple of ways, either by using a non-capturing group or just by dropping the OR entirely since I don't think a \r by itself should be appearing anywhere. I chose to drop the OR entirely, but it'd be trivial to add back in & use a group instead.
For my own sanity I fleshed out the newline tests a bit by adding \r\n tests & a fixture as well, just to make sure I wasn't regressing anything.
Coverage remained the same when pulling c5e8278b84015adc3bf1e543055219cdef756459 on tivac:formatter-newlines into daa9eb154a8fdf7fe291ef0408279df307cf255a on vesln:master.
I started trying to use nixt on a project and while I love the API, it was weirdly stripping the very first
\n
in my stdout/stderr strings. I did some digging around and I'm pretty sure I tracked down why.It has to do with operator precedence inside regexes, here's an example of what is happening. You can fix it in a couple of ways, either by using a non-capturing group or just by dropping the
OR
entirely since I don't think a\r
by itself should be appearing anywhere. I chose to drop theOR
entirely, but it'd be trivial to add back in & use a group instead.For my own sanity I fleshed out the newline tests a bit by adding
\r\n
tests & a fixture as well, just to make sure I wasn't regressing anything.