Repository navigation
Conversation
format-diff called shouldPrintPatch without opts, so --diff-text was ignored and files with binary extensions never got a patch. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
t.resolves(promise, true) treats true as the assertion message, so these tests only checked that the promise did not reject, never what it resolved to. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
npm diff --diff-textcurrently has no effect. The flag sets an option, butoptsis not passed intoshouldPrintPatch(), so no behaviour is changed.Expected behaviour
Diffing a package where
foo.pngis actually plain text:Actual behaviour
--diff-textis ignored, so files with binary extensions only ever get the headers:Why tests didn't catch it
shouldPrintPatchdirectly with{ diffText: true }, so it never goes through the call informatDiff.t.resolves(promise, true). I believe the intention was to check that the promise resolved the valuetrue, but looking atresolves(), the second parameter is actually a message.resolves()actually just checks if a promise resolves, not what it resolves.npm diffcommand test that sets'diff-text': trueuses a fixture with no binary-extension files, so its snapshot is the same either way.Changes
format-diff.js: passoptstoshouldPrintPatch. I figured I could have skipped clalingshouldPrintPatchcompletely if the option is set, but I saw thatshouldPrintPatch()was designed to accept the options, so assuming that actually passing the options to it is the appropiate fix.format-difftest,binary file using --diff-text option, with a.jpganddiffText: true. It fails without the fix.should-print-patchtests to actually assert the returned value, usingequal()Not in scope
When using
--diff-textwith actually binary files, they are still decoded as UTF-8, and thus provides a bad diffing, but I assume that is expected since--diff-textis an option to "force" binaries as text.