mirror of
https://github.com/zed-industries/zed.git
synced 2026-11-28 03:20:58 +01:00
8c4550cb95
# Objective - Fix npm v12 output deserialization - Fixes #60705 ## Solution Initially I was thinking about checking the `npm` version and then parsing its output accordingly but that would include a call to `npm --version`. Zed's mojo is to be blazingly fast so just checking the structure of the output should be enough: 1. `npm info --json` in v12 produces an array with 1 object: `[ { "name": "something" } ]` 2. `npm info --json` in v11 and older produces an object: `{ "name": "something" }` So the trick is to check the output: if it's an array, we have npm v12, otherwise npm v11. ## Testing - Did you test these changes? If so, how? 1. Ensure you have `npm` v12 installed. 2. Install a Node.js based language server, for example, `markdownlint` or `oxfmt` 3. Open a project and trigger start of a language server - Are there any parts that need more testing? no - How can other people (reviewers) test your changes? Is there anything specific they need to know? Use steps above - If relevant, what platforms did you test these changes on, and are there any important ones you can't test? I've tested this on macOS and Linux. ## Self-Review Checklist: - [x] I've reviewed my own diff for quality, security, and reliability - [x] Unsafe blocks (if any) have justifying comments - [ ] The content adheres to Zed's UI standards ([UX/UI](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist) and [icon](https://github.com/zed-industries/zed/blob/main/crates/icons/README.md) guidelines) - [x] Tests cover the new/changed behavior - [x] Performance impact has been considered and is acceptable ## Showcase N/A --- Release Notes: - Fixed npm v12 output deserialization