(lockDir: string, owner: WorkspaceRootLockOwner)
| 81 | } |
| 82 | |
| 83 | function makeLock(lockDir: string, owner: WorkspaceRootLockOwner): WorkspaceProcessLock { |
| 84 | return { |
| 85 | lockDir, |
| 86 | owner, |
| 87 | release: async () => { |
| 88 | const current = await readOwner(lockDir).catch(() => null) |
| 89 | if (current?.token !== owner.token) return |
| 90 | await rm(lockDir, { recursive: true, force: true }) |
| 91 | }, |
| 92 | } |
| 93 | } |
| 94 | |
| 95 | async function writeOwner(lockDir: string, owner: WorkspaceRootLockOwner): Promise<void> { |
| 96 | await writeFile(join(lockDir, OWNER_FILE), JSON.stringify(owner, null, 2) + '\n', 'utf8') |
no test coverage detected