Open
Conversation
This method is used to clone the object returned by `read` before passing it to `update`. This is useful when the object returned by `read` is not trivially cloneable. One use case is when trying to preserve comments in a JSONC file using the `comment-json` package, which uses symbol properties on the object to store comments. The default `clone` method would not preserve these symbol properties, so a custom `clone` method is needed. Fixes pnpm#10
ca14774 to
5b50c13
Compare
zkochan
reviewed
Feb 2, 2024
Member
zkochan
left a comment
There was a problem hiding this comment.
I don't have objections but let's add a test for it.
They're now in the order they are called.
also remove the options parameter from the clone function
Author
|
Hey @zkochan, sorry to bother you, but I was wondering if you could take another look at this and let me know if I can do anything to improve it? |
zkochan
reviewed
Apr 24, 2024
| return fsx.readFile(options.resolvedPath, 'utf8') | ||
| }, | ||
| clone(value) { | ||
| return value |
Member
There was a problem hiding this comment.
maybe also do some manipulations here and see if they were reflected
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.
Adds an optional
clonemethod to theFormatPlugininterface. This method is used to clone the object returned byreadbefore passing it toupdate. This is useful when the object returned byreadis not trivially cloneable.One use case is when trying to preserve comments in a JSONC file using the
comment-jsonpackage, which uses symbol properties on the object to store comments. The defaultclonemethod would not preserve these symbol properties, so a customclonemethod is needed.Fixes #10