From 8e9d6c38b72ba4d76dbbca034d293760d709b75a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Linus=20Unneb=C3=A4ck?= Date: Thu, 21 Feb 2019 14:30:25 +0000 Subject: [PATCH] [proper-lockfile] Add lockfilePath option --- types/proper-lockfile/index.d.ts | 4 ++++ types/proper-lockfile/proper-lockfile-tests.ts | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/types/proper-lockfile/index.d.ts b/types/proper-lockfile/index.d.ts index 885e63808b..3e49e79fe3 100644 --- a/types/proper-lockfile/index.d.ts +++ b/types/proper-lockfile/index.d.ts @@ -1,6 +1,7 @@ // Type definitions for proper-lockfile 3.0 // Project: https://github.com/moxystudio/node-proper-lockfile // Definitions by: Nikita Volodin +// Linus Unnebäck // 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>; diff --git a/types/proper-lockfile/proper-lockfile-tests.ts b/types/proper-lockfile/proper-lockfile-tests.ts index 7555fd5116..344e7be3f8 100644 --- a/types/proper-lockfile/proper-lockfile-tests.ts +++ b/types/proper-lockfile/proper-lockfile-tests.ts @@ -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