fix(arborist): handle scripts set to null during rebuild#9185
Open
ap-b12 wants to merge 1 commit intonpm:latestfrom
Open
fix(arborist): handle scripts set to null during rebuild#9185ap-b12 wants to merge 1 commit intonpm:latestfrom
ap-b12 wants to merge 1 commit intonpm:latestfrom
Conversation
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.
Bug
Destructuring
scriptswhen set tonullthrows aTypeError:Problem
Even though there (seemingly) is a fallback in place when destructuring an object with
scripts, this only works forundefined:When dealing with JSON, of course,
undefinedis not even a valid value in the first place, sonullbecomes the go-to alternative.Fix
The solution is to handle
scriptsgracefully:Compared to:
|| {}forscriptsalready exists in some places, but was missing fromworkspaces/arborist/lib/arborist/rebuild.js.Note: At least in the following case,
scripts = {}is still needed, as confirmed by current tests.Test
A test was added to
workspaces/arborist/test/arborist/rebuild.js.[✓] Without the fix, the test fails.
[✓] After applying the fix, the test passes.
References
No existing issue could be found.