(server: LspServerDefinition)
| 437 | } |
| 438 | |
| 439 | function buildUninstallCommand(server: LspServerDefinition): string | null { |
| 440 | const spec = normalizeInstallSpec(server); |
| 441 | if (!spec) return null; |
| 442 | |
| 443 | if (spec.uninstallCommand) { |
| 444 | return spec.uninstallCommand; |
| 445 | } |
| 446 | if (server.launcher?.uninstallCommand) { |
| 447 | return server.launcher.uninstallCommand; |
| 448 | } |
| 449 | |
| 450 | switch (spec.kind) { |
| 451 | case "apk": |
| 452 | return spec.packages.length |
| 453 | ? `apk del ${spec.packages.map((entry) => quoteArg(entry)).join(" ")}` |
| 454 | : null; |
| 455 | case "npm": { |
| 456 | if (!spec.packages.length) return null; |
| 457 | const npmCommand = spec.npmCommand || "npm"; |
| 458 | const uninstallFlags = |
| 459 | spec.global !== false ? "uninstall -g" : "uninstall"; |
| 460 | return `${npmCommand} ${uninstallFlags} ${spec.packages.map((entry) => quoteArg(entry)).join(" ")}`; |
| 461 | } |
| 462 | case "pip": |
| 463 | return spec.packages.length |
| 464 | ? `${spec.pipCommand || "pip"} uninstall -y ${spec.packages.map((entry) => quoteArg(entry)).join(" ")}` |
| 465 | : null; |
| 466 | case "cargo": |
| 467 | return spec.packages.length |
| 468 | ? spec.packages |
| 469 | .map((entry) => `cargo uninstall ${quoteArg(entry)}`) |
| 470 | .join(" && ") |
| 471 | : null; |
| 472 | case "github-release": |
| 473 | case "manual": |
| 474 | return spec.binaryPath ? `rm -f ${quoteArg(spec.binaryPath)}` : null; |
| 475 | default: |
| 476 | return null; |
| 477 | } |
| 478 | } |
| 479 | |
| 480 | function buildInstallCommand( |
| 481 | server: LspServerDefinition, |
no test coverage detected