MCPcopy Create free account
hub / github.com/Acode-Foundation/Acode / ensureInstalled

Function ensureInstalled

src/cm/lsp/serverLauncher.ts:674–710  ·  view source on GitHub ↗
(server: LspServerDefinition)

Source from the content-addressed store, hash-verified

672}
673
674async function ensureInstalled(server: LspServerDefinition): Promise<boolean> {
675 const launcher = server.launcher;
676 const checkCommand =
677 launcher?.checkCommand || buildDerivedCheckCommand(server);
678 if (!checkCommand) return true;
679
680 const cacheKey = getInstallCacheKey(server);
681 if (!cacheKey) return true;
682
683 // Return cached result if already checked
684 if (checkedCommands.has(cacheKey)) {
685 const status = checkedCommands.get(cacheKey);
686 if (status === STATUS_PRESENT) {
687 return true;
688 }
689 if (status === STATUS_DECLINED) {
690 return false;
691 }
692 checkedCommands.delete(cacheKey);
693 }
694
695 // If there's already a pending check for this server, wait for it
696 if (pendingInstallChecks.has(cacheKey)) {
697 const pending = pendingInstallChecks.get(cacheKey);
698 if (pending) return pending;
699 }
700
701 // Create and track the pending promise
702 const checkPromise = performInstallCheck(server, launcher, cacheKey);
703 pendingInstallChecks.set(cacheKey, checkPromise);
704
705 try {
706 return await checkPromise;
707 } finally {
708 pendingInstallChecks.delete(cacheKey);
709 }
710}
711
712interface LoaderDialog {
713 show: () => void;

Callers 1

ensureServerRunningFunction · 0.85

Calls 6

buildDerivedCheckCommandFunction · 0.85
getInstallCacheKeyFunction · 0.85
performInstallCheckFunction · 0.85
setMethod · 0.80
deleteMethod · 0.65
getMethod · 0.45

Tested by

no test coverage detected