DefinitelyTyped/types/proper-lockfile/index.d.ts
Simon Holywell 64fcb11aae [proper-lockfile] Patches options.retries with the correct type (#37313)
* Types options.retries with correct type

`proper-lockfile` is calling `retry.operation()` underneath so the correct type to use
for `LockOptions.retries` is `retry.OperationOptions` and not the more restricted
`retry.TimeoutsOptions`.

* Adds regression test for #37313
2019-08-05 13:43:36 -07:00

41 lines
1.6 KiB
TypeScript

// Type definitions for proper-lockfile 4.1
// Project: https://github.com/moxystudio/node-proper-lockfile
// Definitions by: Nikita Volodin <https://github.com/qlonik>
// Linus Unnebäck <https://github.com/LinusU>
// ulrichb <https://github.com/ulrichb>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.3
import { OperationOptions } from "retry";
export interface LockOptions {
stale?: number; // default: 10000
update?: number; // default: stale/2
retries?: number | OperationOptions; // default: 0
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>>;
export function unlock(file: string, options?: UnlockOptions): Promise<void>;
export function check(file: string, options?: CheckOptions): Promise<boolean>;
export function lockSync(file: string, options?: LockOptions): () => void;
export function unlockSync(file: string, options?: UnlockOptions): void;
export function checkSync(file: string, options?: CheckOptions): boolean;