(server: LspServerDefinition)
| 325 | } |
| 326 | |
| 327 | function normalizeInstallSpec(server: LspServerDefinition) { |
| 328 | const install = server.launcher?.install; |
| 329 | if (!install) return null; |
| 330 | |
| 331 | const packages = Array.isArray(install.packages) |
| 332 | ? install.packages |
| 333 | .map((entry) => String(entry || "").trim()) |
| 334 | .filter(Boolean) |
| 335 | : []; |
| 336 | const kind = |
| 337 | install.kind || |
| 338 | (install.binaryPath ? "manual" : null) || |
| 339 | (install.source === "apk" ? "apk" : null) || |
| 340 | (install.source === "npm" ? "npm" : null) || |
| 341 | (install.source === "pip" ? "pip" : null) || |
| 342 | (install.source === "cargo" ? "cargo" : null) || |
| 343 | (install.command ? "shell" : null) || |
| 344 | "shell"; |
| 345 | |
| 346 | return { |
| 347 | ...install, |
| 348 | kind, |
| 349 | packages, |
| 350 | command: |
| 351 | typeof install.command === "string" && install.command.trim() |
| 352 | ? install.command.trim() |
| 353 | : undefined, |
| 354 | updateCommand: |
| 355 | typeof install.updateCommand === "string" && install.updateCommand.trim() |
| 356 | ? install.updateCommand.trim() |
| 357 | : undefined, |
| 358 | source: |
| 359 | install.source || |
| 360 | (kind === "shell" ? "custom" : kind === "manual" ? "manual" : kind), |
| 361 | executable: |
| 362 | typeof install.executable === "string" && install.executable.trim() |
| 363 | ? install.executable.trim() |
| 364 | : undefined, |
| 365 | binaryPath: |
| 366 | typeof install.binaryPath === "string" && install.binaryPath.trim() |
| 367 | ? install.binaryPath.trim() |
| 368 | : undefined, |
| 369 | repo: |
| 370 | typeof install.repo === "string" && install.repo.trim() |
| 371 | ? install.repo.trim() |
| 372 | : undefined, |
| 373 | assetNames: |
| 374 | install.assetNames && typeof install.assetNames === "object" |
| 375 | ? Object.fromEntries( |
| 376 | Object.entries(install.assetNames) |
| 377 | .map(([key, value]) => [String(key), String(value || "").trim()]) |
| 378 | .filter(([, value]) => Boolean(value)), |
| 379 | ) |
| 380 | : {}, |
| 381 | archiveType: install.archiveType === "binary" ? "binary" : "zip", |
| 382 | extractFile: |
| 383 | typeof install.extractFile === "string" && install.extractFile.trim() |
| 384 | ? install.extractFile.trim() |
no test coverage detected