Skip to content

feat(arborist): add toJSON/toString methods to get shrinkwrap file contents without saving - #4181

Merged
nlf merged 1 commit into
npm:release-nextfrom
ljharb:release-next
Jan 6, 2022
Merged

feat(arborist): add toJSON/toString methods to get shrinkwrap file contents without saving#4181
nlf merged 1 commit into
npm:release-nextfrom
ljharb:release-next

Conversation

@ljharb

Copy link
Copy Markdown
Contributor

This allows me to build a tool that gets the lockfile's contents without touching the filesystem.

@ljharb
ljharb requested a review from a team as a code ownerDecember 18, 2021 06:12
@isaacs

Copy link
Copy Markdown
Contributor

Seems like a toJSON method should return an object, not a string, so that JSON.stringify(shrinkwrapObject) will return the JSON representation of the shrinkwrap object, rather than the JSON representation of the JSON string itself.

@ljharb

Copy link
Copy Markdown
ContributorAuthor

ah, good call.

given that what i need is the formatted string, do you have a thought for a better choice of method name? I could also make toJSON return an object, and then have another method that calls that, and formats it, and then have save call that, but that seems like overkill.

@ljharbljharb changed the title [arborist] [refactor] Shrinkwrap: add toJSON method to get shrinkwrap file contents without saving[arborist] [refactor] Shrinkwrap: add toJSON/toString methods to get shrinkwrap file contents without savingDec 21, 2021
@ljharb

Copy link
Copy Markdown
ContributorAuthor

k, went with toString :-) updated!

nlf
nlf approved these changes Dec 28, 2021
@fritzyfritzy changed the title [arborist] [refactor] Shrinkwrap: add toJSON/toString methods to get shrinkwrap file contents without savingfeat(arborist): add toJSON/toString methods to get shrinkwrap file contents without savingJan 5, 2022
@fritzyfritzy added the ws:arborist Related to the arborist workspace label Jan 5, 2022
@nlf
nlf merged commit 3cfae38 into npm:release-nextJan 6, 2022
@ljharb
ljharb deleted the release-next branch January 6, 2022 19:54
@fritzyfritzy mentioned this pull request Jan 13, 2022
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ws:arboristRelated to the arborist workspace

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

@ljharb@isaacs@nlf@fritzy