@oh-my-pi/pi-utils 18.14.0 → 18.14.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/dist/types/file-lock.d.ts +6 -0
- package/package.json +2 -2
- package/src/file-lock.ts +9 -0
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
## [Unreleased]
|
|
4
4
|
|
|
5
|
+
## [18.14.1] - 2026-10-31
|
|
6
|
+
|
|
7
|
+
### Added
|
|
8
|
+
|
|
9
|
+
- Added `isFileLockHeld`, which reports whether a file lock is held without acquiring it ([#17428](https://github.com/can1357/oh-my-pi/pull/17428) by [@andrebrait](https://github.com/andrebrait))
|
|
10
|
+
|
|
5
11
|
## [18.14.0] - 2026-10-29
|
|
6
12
|
|
|
7
13
|
### Added
|
|
@@ -16,6 +16,12 @@ declare function getLockPath(filePath: string): string;
|
|
|
16
16
|
declare function tryAcquireLock(lockPath: string): NativeFileLock | null;
|
|
17
17
|
/** Acquire an exclusive lease without waiting; `null` while another holder owns it. */
|
|
18
18
|
export declare function tryAcquireFileLock(filePath: string): FileLockHandle | null;
|
|
19
|
+
/**
|
|
20
|
+
* Whether any holder, including this process, owns the lease, observed without
|
|
21
|
+
* taking it, so a concurrent `tryAcquireFileLock` never meets the probe.
|
|
22
|
+
* Throws when the lock cannot be probed.
|
|
23
|
+
*/
|
|
24
|
+
export declare function isFileLockHeld(filePath: string): boolean;
|
|
19
25
|
/** Acquire an exclusive lease; callers must release it when their operation ends. */
|
|
20
26
|
export declare function acquireFileLock(filePath: string, options?: FileLockOptions): Promise<FileLockHandle>;
|
|
21
27
|
/** Run `fn` while holding an OS-backed exclusive lock for `filePath`. */
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oh-my-pi/pi-utils",
|
|
3
|
-
"version": "18.14.
|
|
3
|
+
"version": "18.14.1",
|
|
4
4
|
"description": "Shared utilities for pi packages",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cli",
|
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
"fmt": "oxfmt --no-error-on-unmatched-pattern 'src/**/*.{ts,tsx}' '{test,bench,examples,scripts}/**/*.ts' '*.ts'"
|
|
57
57
|
},
|
|
58
58
|
"dependencies": {
|
|
59
|
-
"@oh-my-pi/pi-natives": "18.14.
|
|
59
|
+
"@oh-my-pi/pi-natives": "18.14.1"
|
|
60
60
|
},
|
|
61
61
|
"devDependencies": {
|
|
62
62
|
"@types/bun": "^1.3.14"
|
package/src/file-lock.ts
CHANGED
|
@@ -44,6 +44,15 @@ export function tryAcquireFileLock(filePath: string): FileLockHandle | null {
|
|
|
44
44
|
return tryAcquireLock(getLockPath(filePath));
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
+
/**
|
|
48
|
+
* Whether any holder, including this process, owns the lease, observed without
|
|
49
|
+
* taking it, so a concurrent `tryAcquireFileLock` never meets the probe.
|
|
50
|
+
* Throws when the lock cannot be probed.
|
|
51
|
+
*/
|
|
52
|
+
export function isFileLockHeld(filePath: string): boolean {
|
|
53
|
+
return NativeFileLock.isHeld(getLockPath(filePath));
|
|
54
|
+
}
|
|
55
|
+
|
|
47
56
|
/** Acquire an exclusive lease; callers must release it when their operation ends. */
|
|
48
57
|
export async function acquireFileLock(filePath: string, options: FileLockOptions = {}): Promise<FileLockHandle> {
|
|
49
58
|
const opts = { ...DEFAULT_OPTIONS, ...options };
|