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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from
Jan 6, 2022

Conversation

ljharb
Copy link
Contributor

@ljharb ljharb commented Dec 18, 2021

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 owner December 18, 2021 06:12
@isaacs
Copy link
Contributor

isaacs commented Dec 21, 2021

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
Contributor Author

ljharb commented Dec 21, 2021

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.

…o get shrinkwrap contents without saving
@ljharb ljharb 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 saving Dec 21, 2021
@ljharb
Copy link
Contributor Author

ljharb commented Dec 21, 2021

k, went with toString :-) updated!

@fritzy fritzy changed the title [arborist] [refactor] Shrinkwrap: add toJSON/toString methods to get shrinkwrap file contents without saving feat(arborist): add toJSON/toString methods to get shrinkwrap file contents without saving Jan 5, 2022
@fritzy fritzy added the ws:arborist Related to the arborist workspace label Jan 5, 2022
@nlf nlf merged commit 3cfae38 into npm:release-next Jan 6, 2022
@ljharb ljharb deleted the release-next branch January 6, 2022 19:54
@fritzy fritzy mentioned this pull request Jan 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ws:arborist Related to the arborist workspace
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants