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

Use .sortedKeys for JSONEncoder, so output is stable #68

Merged
merged 1 commit into from
Oct 30, 2023

Conversation

m4p
Copy link
Contributor

@m4p m4p commented Oct 30, 2023

When using swift-package-list as part of our toolchain, JSON output often changes despite the licenses not changing.

It seems .prettyPrint keys aren't sorted, and so the order of the JSON keys can fluctuate. I'd propose using .sortedKeys instead, so we can store the json in our git without generating superfluous changes.

@m4p
Copy link
Contributor Author

m4p commented Oct 30, 2023

(Happy to fix the failing test, if you agree with this change)

@FelixHerrmann
Copy link
Owner

Hi, thanks for your contribution! That's def. a reasonable thing to add, interestingly it was never a problem in the project where I use this tool (had id configured as Run Script + file in source control before switching to SPM plugin). I don't want to get rid of the .prettyPrinted option tho because it really helps readability (especially in commits). Please adjust this and then we can get this change in; tests should also not fail after that change!

@m4p
Copy link
Contributor Author

m4p commented Oct 30, 2023

Sure thing! Did just push the change.

@FelixHerrmann
Copy link
Owner

Looking good now, thanks for the adjustments. Will release that shortly!

@FelixHerrmann FelixHerrmann merged commit c4ec56f into FelixHerrmann:master Oct 30, 2023
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

Successfully merging this pull request may close these issues.

2 participants