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 sort_by to preserve user-defined order of package installs #479

Merged
merged 2 commits into from Jun 20, 2019

Conversation

charlespierce
Copy link
Contributor

Closes #478

Use sort_by and specify an ordering function to do the sorting of tools. That sorting function explicitly treats Node as the lowest, followed by Npm, Yarn, and Packages, but within each category it ignores the specifics and treats all tools as the same.

Per the rust docs, Vec::sort_by is stable, so by treating all of the Packages as equal, the original order (provided by the user) will be preserved.

Note: We use sort_by as opposed to a custom implementation of the Ord trait because the docs specify that the implementations of Ord and PartialEq must match exactly, and we use the derived PartialEq implementation elsewhere so it can't be changed.

@rwjblue
Copy link
Contributor

rwjblue commented Jun 19, 2019

Thank you for working on this! The current behavior confused me when I first noticed it.

Copy link
Contributor

@chriskrycho chriskrycho left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this! One strongly-recommended tweak, and then a set of nits you can totally feel free to ignore. 😆

crates/volta-core/src/tool/mod.rs Outdated Show resolved Hide resolved
crates/volta-core/src/tool/mod.rs Outdated Show resolved Hide resolved
@charlespierce charlespierce added bug and removed bug labels Jun 19, 2019
Copy link
Contributor

@chriskrycho chriskrycho left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚡️

@chriskrycho chriskrycho merged commit 2528cde into volta-cli:master Jun 20, 2019
@charlespierce charlespierce deleted the preserve_package_order branch June 28, 2019 04:50
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.

volta install shouldn't change the order of packages
3 participants