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

Function locateWrapper

apps/desktop/src/main/cli-install.ts:46–75  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

44}
45
46async function locateWrapper(): Promise<WrapperLocation | null> {
47 const candidates: WrapperLocation[] = []
48
49 if (app.isPackaged) {
50 candidates.push({
51 wrapperPath: path.join(process.resourcesPath, WRAPPER_NAME),
52 cliJsPath: path.join(process.resourcesPath, 'cli.js')
53 })
54 }
55
56 const here = path.dirname(fileURLToPath(import.meta.url))
57 const devCliJs = path.join(here, 'cli.js')
58 candidates.push({
59 wrapperPath: await ensureDevWrapper(devCliJs),
60 cliJsPath: devCliJs
61 })
62
63 for (const c of candidates) {
64 try {
65 const [wrapperStat, cliStat] = await Promise.all([
66 fsp.stat(c.wrapperPath),
67 fsp.stat(c.cliJsPath)
68 ])
69 if (wrapperStat.isFile() && cliStat.isFile()) return c
70 } catch {
71 /* keep trying */
72 }
73 }
74 return null
75}
76
77async function ensureDevWrapper(cliJsPath: string): Promise<string> {
78 const dir = path.join(app.getPath('userData'), 'cli')

Callers 3

getCliInstallStatusFunction · 0.85
installCliFunction · 0.85
uninstallCliFunction · 0.85

Calls 1

ensureDevWrapperFunction · 0.85

Tested by

no test coverage detected