(lockDir: string)
| 97 | } |
| 98 | |
| 99 | async function readOwner(lockDir: string): Promise<WorkspaceRootLockOwner> { |
| 100 | const raw = await readFile(join(lockDir, OWNER_FILE), 'utf8') |
| 101 | const parsed = JSON.parse(raw) as Partial<WorkspaceRootLockOwner> |
| 102 | if ( |
| 103 | typeof parsed.pid !== 'number' || |
| 104 | typeof parsed.hostname !== 'string' || |
| 105 | typeof parsed.token !== 'string' || |
| 106 | typeof parsed.acquiredAt !== 'string' |
| 107 | ) { |
| 108 | throw new Error('invalid workspace root lock owner') |
| 109 | } |
| 110 | return { |
| 111 | pid: parsed.pid, |
| 112 | hostname: parsed.hostname, |
| 113 | token: parsed.token, |
| 114 | acquiredAt: parsed.acquiredAt, |
| 115 | } |
| 116 | } |
| 117 | |
| 118 | function defaultIsProcessAlive(pid: number, hostname: string): boolean { |
| 119 | if (hostname !== osHostname()) return true |
no test coverage detected