Merge pull request #33271 from LinusU/lockfile-path

[proper-lockfile] Add lockfilePath option
This commit is contained in:
Jesse Trinity
2019-02-26 14:38:38 -08:00
committed by GitHub
2 changed files with 9 additions and 0 deletions
+4
View File
@@ -1,6 +1,7 @@
// Type definitions for proper-lockfile 3.0
// Project: https://github.com/moxystudio/node-proper-lockfile
// Definitions by: Nikita Volodin <https://github.com/qlonik>
// Linus Unnebäck <https://github.com/LinusU>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
export interface LockOptions {
@@ -10,17 +11,20 @@ export interface LockOptions {
realpath?: boolean; // default: true
fs?: any; // default: graceful-fs
onCompromised?: (err: Error) => any; // default: (err) => throw err
lockfilePath?: string; // default: `${file}.lock`
}
export interface UnlockOptions {
realpath?: boolean; // default: true
fs?: any; // default: graceful-fs
lockfilePath?: string; // default: `${file}.lock`
}
export interface CheckOptions {
stale?: number; // default: 10000
realpath?: boolean; // default: true
fs?: any; // default: graceful-fs
lockfilePath?: string; // default: `${file}.lock`
}
export function lock(file: string, options?: LockOptions): Promise<() => Promise<void>>;
@@ -39,7 +39,12 @@ check('some/file')
// isLocked will be true if 'some/file' is locked, false otherwise
});
lock('', { lockfilePath: 'some/file-lock' })
.then((release) => release());
const release = lockSync('some/file'); // $ExpectType () => void
release(); // $ExpectType void
unlockSync('some/file'); // $ExpectType void
unlockSync('', { lockfilePath: 'some/file-lock' }); // $ExpectType void
checkSync('some/file'); // $ExpectType boolean
checkSync('', { lockfilePath: 'some/file-lock' }); // $ExpectType boolean