Files
oh-my-pi/packages/utils/test/fixtures/file-lock-holder.ts
T
can1357 455493dfad feat: introduced native file lock bindings for cross-process advisory locking
- Added native `FileLock` bindings supporting cross-process advisory locking on Linux, Unix, and Windows.
- Replaced directory-based file locking and custom stale-lock reclamation with OS-backed native locks.
- Updated TypeScript declarations, native bindings, and package documentation for the new API.
- Added comprehensive unit tests and fixtures validating single-owner constraints and process death handoff.
2026-08-03 16:09:09 +02:00

15 lines
401 B
TypeScript

import { withFileLock } from "../../src/file-lock";
const target = Bun.argv[2];
const readyPath = Bun.argv[3];
if (!target || !readyPath) throw new Error("file-lock-holder requires target and readiness paths");
await withFileLock(
target,
async () => {
await Bun.write(readyPath, "ready");
Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0);
},
{ retries: 1, retryDelayMs: 0 },
);