You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've recently created a RFC (npm/rfcs#522) for npm diff to have an option to ignore cr to allow better diffing between platforms.
The problem with npm diff is that if you're developing on a Windows machine and want to compare it to a package built on UNIX, or vice versa, every line will appear as changed since the lineendings are different.
While investigating how this would be implemented, I notice that diff does not have an option for something like this. I tried to find any previous issues/PRs that talked about this but only really found #68 which seems more concerned with separating lines from lineendings (correct me if I'm wrong) and only mentions crlf in passing.
It does mention that diffTrimmedLines() should ignore line endings since it should trim the lines, but as far as I can tell, this is not the case currently ([email protected]). I tested in a simple example setup.
Would an option similar to those in git/GNU diff make sense in jsdiff too, or is this against the nature of this package?
In the previously mentioned issue, there is also a new method, which is now an option, the newlineIsToken option which treats line endings as separate tokens, so I suppose it would be possible to use diffLines() with newLineIsToken: true and then parse the diff to ignore changes to line ending tokens (CRLF and LF). There is no such support in the patch methods as far as I can tell.
It should be mentioned that it would of course be possible to preprocess data before it's passed to jsdiff to convert all CRLF ▶ LF and thus get a proper diff without modifying jsdiff. Is an option unecessary and/or unwanted? 🤔
Hello!
I've recently created a RFC (npm/rfcs#522) for
npm diff
to have an option to ignorecr
to allow better diffing between platforms.The problem with
npm diff
is that if you're developing on a Windows machine and want to compare it to a package built on UNIX, or vice versa, every line will appear as changed since the lineendings are different.In the RFC I mention
git diff --ignore-cr-at-eol
and GNUdiff --strip-trailing-cr
as prior art.While investigating how this would be implemented, I notice that
diff
does not have an option for something like this. I tried to find any previous issues/PRs that talked about this but only really found #68 which seems more concerned with separating lines from lineendings (correct me if I'm wrong) and only mentions crlf in passing.It does mention that
diffTrimmedLines()
should ignore line endings since it should trim the lines, but as far as I can tell, this is not the case currently ([email protected]). I tested in a simple example setup.Would an option similar to those in git/GNU diff make sense in jsdiff too, or is this against the nature of this package?
In the previously mentioned issue, there is also a new method, which is now an option, the
newlineIsToken
option which treats line endings as separate tokens, so I suppose it would be possible to usediffLines()
withnewLineIsToken: true
and then parse the diff to ignore changes to line ending tokens (CRLF and LF). There is no such support in the patch methods as far as I can tell.(Probable duplicate: #275)
The text was updated successfully, but these errors were encountered: