MCPcopy Create free account
hub / github.com/MoonshotAI/kimi-code / readLockContents

Function readLockContents

packages/server/src/lock.ts:129–146  ·  view source on GitHub ↗

Read + JSON.parse the lock file; returns undefined on any error so callers can fall through.

(path: string)

Source from the content-addressed store, hash-verified

127
128/** Read + JSON.parse the lock file; returns undefined on any error so callers can fall through. */
129function readLockContents(path: string): LockContents | undefined {
130 try {
131 const raw = readFileSync(path, 'utf8');
132 const parsed = JSON.parse(raw) as unknown;
133 if (
134 typeof parsed === 'object' &&
135 parsed !== null &&
136 typeof (parsed as LockContents).pid === 'number' &&
137 typeof (parsed as LockContents).started_at === 'string' &&
138 typeof (parsed as LockContents).port === 'number'
139 ) {
140 return parsed as LockContents;
141 }
142 return undefined;
143 } catch {
144 return undefined;
145 }
146}
147
148/**
149 * Read the lock file and return its contents only when it describes a *live*

Callers 4

getLiveLockFunction · 0.85
acquireLockFunction · 0.85
releaseFunction · 0.85
updatePortFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected