fix: link --name prefers exact match if exists, first match otherwise
🎉 Thanks for submitting a pull request! 🎉
Summary
If ntl link --name <name> matched multiple site names, it previously linked the first site name listed, even if there was an exact match. This fix makes ntl link --name <name> prefer an exact match if there is one. It follows previous behavior if there is not an exact match.
Fixes # From internal ticket system
In netlify-react-ui, I ran ntl link --name app, and it connected me to next-app-playground. It should’ve connected me to app. The reason is that in https://github.com/netlify/cli/blob/79732adbc486516a2d2e244d0d160bacb94c34af/src/commands/link/link.ts#L303-L334, it’s always selecting the first site in the search result. Instead, it should check if there’s an exact match, and use that if it exists.
For us to review and ship your PR efficiently, please perform the following steps:
- [ ] Open a bug/issue before writing your code 🧑💻. This ensures we can discuss the changes and get feedback from everyone that should be involved. If you`re fixing a typo or something that`s on fire 🔥 (e.g. incident related), you can skip this step.
- [ ] Read the contribution guidelines 📖. This ensures your code follows our style guide and passes our tests.
- [ ] Update or add tests (if any source code was changed or added) 🧪
- [ ] Update or add documentation (if features were changed or added) 📝
- [ ] Make sure the status checks below are successful ✅
A picture of a cute animal (not mandatory, but encouraged)
@DanielSLew thanks for the feedback! I added the suggestions.