MCPcopy Create free account
hub / github.com/AnukarOP/claude-code-leaked / getDesktopVersion

Function getDesktopVersion

source code/utils/desktopDeepLink.ts:91–129  ·  view source on GitHub ↗

* Detect the installed Claude Desktop version. * On macOS, reads CFBundleShortVersionString from the app plist. * On Windows, finds the highest app-X.Y.Z directory in the Squirrel install. * Returns null if version cannot be determined.

()

Source from the content-addressed store, hash-verified

89 * Returns null if version cannot be determined.
90 */
91async function getDesktopVersion(): Promise<string | null> {
92 const platform = process.platform
93
94 if (platform === 'darwin') {
95 const { code, stdout } = await execFileNoThrow('defaults', [
96 'read',
97 '/Applications/Claude.app/Contents/Info.plist',
98 'CFBundleShortVersionString',
99 ])
100 if (code !== 0) {
101 return null
102 }
103 const version = stdout.trim()
104 return version.length > 0 ? version : null
105 } else if (platform === 'win32') {
106 const localAppData = process.env.LOCALAPPDATA
107 if (!localAppData) {
108 return null
109 }
110 const installDir = join(localAppData, 'AnthropicClaude')
111 try {
112 const entries = await readdir(installDir)
113 const versions = entries
114 .filter(e => e.startsWith('app-'))
115 .map(e => e.slice(4))
116 .filter(v => semverCoerce(v) !== null)
117 .sort((a, b) => {
118 const ca = semverCoerce(a)!
119 const cb = semverCoerce(b)!
120 return ca.compare(cb)
121 })
122 return versions.length > 0 ? versions[versions.length - 1]! : null
123 } catch {
124 return null
125 }
126 }
127
128 return null
129}
130
131export type DesktopInstallStatus =
132 | { status: 'not-installed' }

Callers 1

getDesktopInstallStatusFunction · 0.85

Calls 2

execFileNoThrowFunction · 0.85
readdirFunction · 0.85

Tested by

no test coverage detected