[proper-lockfile] Add lockfilePath option

This commit is contained in:
Linus Unnebäck 2019-02-21 14:30:25 +00:00
parent 351eeb6186
commit 8e9d6c38b7
No known key found for this signature in database
GPG Key ID: CE70CEAE9C0FA66F
2 changed files with 9 additions and 0 deletions

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>>;

View File

@ -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