-
-
Notifications
You must be signed in to change notification settings - Fork 197
/
Copy pathlock-service.d.ts
33 lines (29 loc) · 1.33 KB
/
lock-service.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import * as lockfile from "lockfile";
declare global {
interface ILockOptions extends lockfile.Options { }
/**
* Describes methods that can be used to use file locking.
*/
interface ILockService {
/**
* @param action The code to be locked.
* @param {string} lockFilePath Path to lock file that has to be created. Defaults to `<profile dir>/lockfile.lock`
* @param {ILockOptions} lockOpts Options used for creating the lock file.
* @returns {Promise<T>}
*/
executeActionWithLock<T>(action: () => Promise<T>, lockFilePath?: string, lockOpts?: ILockOptions): Promise<T>
// TODO: expose as decorator
/**
* Wait until the `unlock` method is called for the specified file
* @param {string} lockFilePath Path to lock file that has to be created. Defaults to `<profile dir>/lockfile.lock`
* @param {ILockOptions} lockOpts Options used for creating the lock file.
* @returns {Promise<T>}
*/
lock(lockFilePath?: string, lockOpts?: ILockOptions): Promise<string>
/**
* Resolve the lock methods for the specified file
* @param {string} lockFilePath Path to lock file that has to be removed. Defaults to `<profile dir>/lockfile.lock`
*/
unlock(lockFilePath?: string): void
}
}