MCPcopy Create free account
hub / github.com/ZenNotes/zennotes / removeManagedLinks

Function removeManagedLinks

apps/desktop/src/main/cli-install.ts:316–342  ·  view source on GitHub ↗
(
  names: readonly string[],
  wrapper: WrapperLocation | null
)

Source from the content-addressed store, hash-verified

314 * Zen Browser's `zen`. (#126)
315 */
316export async function removeManagedLinks(
317 names: readonly string[],
318 wrapper: WrapperLocation | null
319): Promise<string[]> {
320 const removed: string[] = []
321 for (const dir of candidateDirs()) {
322 for (const name of names) {
323 const candidate = path.join(dir, name)
324 try {
325 const linkTarget = await fsp.readlink(candidate)
326 const resolved = path.isAbsolute(linkTarget)
327 ? linkTarget
328 : path.resolve(dir, linkTarget)
329 const byUs = wrapper
330 ? sameFile(resolved, wrapper.wrapperPath)
331 : looksLikeOurInstall(resolved)
332 if (byUs) {
333 await fsp.rm(candidate, { force: true })
334 removed.push(candidate)
335 }
336 } catch {
337 /* not a symlink / missing / unreadable — leave it alone */
338 }
339 }
340 }
341 return removed
342}
343
344/* ---------- Install --------------------------------------------------- */
345

Callers 3

installCliFunction · 0.85
uninstallCliFunction · 0.85

Calls 3

candidateDirsFunction · 0.85
sameFileFunction · 0.85
looksLikeOurInstallFunction · 0.85

Tested by

no test coverage detected