Home > @microsoft/node-core-library > LockFile > tryAcquire

LockFile.tryAcquire() method

Attempts to create a lockfile with the given filePath. If successful, returns a LockFile instance. If unable to get a lock, returns undefined.

Signature:

static tryAcquire(resourceDir: string, resourceName: string): LockFile | undefined;

Parameters

Parameter Type Description
resourceDir string  
resourceName string the name of the resource we are locking on. Should be an alphabetic string.

Returns:

LockFile | undefined