MCPcopy Index your code
hub / github.com/CodebuffAI/codebuff / readOwner

Function readOwner

cli/src/utils/freebuff-instance-owner.ts:16–33  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

14const getOwnerPath = (): string => path.join(getConfigDir(), OWNER_FILE)
15
16function readOwner(): FreebuffInstanceOwner | null {
17 try {
18 const raw = fs.readFileSync(getOwnerPath(), 'utf8')
19 const parsed = JSON.parse(raw) as Partial<FreebuffInstanceOwner>
20 if (
21 typeof parsed.instanceId !== 'string' ||
22 typeof parsed.pid !== 'number'
23 ) {
24 return null
25 }
26 return {
27 instanceId: parsed.instanceId,
28 pid: parsed.pid,
29 }
30 } catch {
31 return null
32 }
33}
34
35function isProcessRunning(pid: number): boolean {
36 if (!Number.isInteger(pid) || pid <= 0) return false

Calls 2

getOwnerPathFunction · 0.85
parseMethod · 0.80

Tested by

no test coverage detected