Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose the "formatPatch" function #399

Closed
joffreyvillard opened this issue May 4, 2023 · 7 comments
Closed

Expose the "formatPatch" function #399

joffreyvillard opened this issue May 4, 2023 · 7 comments

Comments

@joffreyvillard
Copy link

joffreyvillard commented May 4, 2023

Hi! 馃憢

Firstly, thanks for your work on this project! 馃檪

Today I used patch-package to patch diff@5.1.0 for the project I'm working on.

I'd like to use the provided formatPatch function along with structuredPatch, so that to only display a diff if relevant to my application (cannot apply the conditions on a string representation of the diff, sounds pretty hacky and fragile!).

I think that formatPatch should hence be exported, to be used together with structuredPatch as I see fit, instead of directly via createTwoFilesPatch that simply combines (and is very suitable anyway!)

Here is the diff that solved my problem:

diff --git a/node_modules/diff/dist/diff.js b/node_modules/diff/dist/diff.js
index 7fa3a55..f7b3efd 100644
--- a/node_modules/diff/dist/diff.js
+++ b/node_modules/diff/dist/diff.js
@@ -1618,6 +1618,7 @@ OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
   exports.diffTrimmedLines = diffTrimmedLines;
   exports.diffWords = diffWords;
   exports.diffWordsWithSpace = diffWordsWithSpace;
+  exports.formatPatch = formatPatch;
   exports.merge = merge;
   exports.parsePatch = parsePatch;
   exports.structuredPatch = structuredPatch;

This issue body was partially generated by patch-package.

@ExplodingCabbage
Copy link
Collaborator

Done! #451

@joffreyvillard
Copy link
Author

Thank you!

@martolini
Copy link

Any chance this can make it to npm, too? 鉂わ笍

@ExplodingCabbage
Copy link
Collaborator

Will do in the next few days, @martolini!

@leonardobsjr
Copy link

It's unfortunate that @type/diff doesn't expose this yet :|

@ExplodingCabbage
Copy link
Collaborator

@leonardobsjr I'm hoping to do #303 soon and have jsdiff take over its own type definitions instead of deferring the provision of them to DefinitelyTyped. I have absolutely no idea how to do this yet - first time! - so any help would be welcome. But if I succeed then the @typed/diff package will be deprecated and there'll be full and correct type in diff itself.

@leonardobsjr
Copy link

@ExplodingCabbage Did a super-barebones types inclusion: #496

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants