# process-lockfile

> Lockfiles for Node.js with extended capabilities

Latest version **1.0.1** (published 2017-11-16) · MIT license · 0 weekly downloads

## Install

```sh
npm install process-lockfile
pnpm add process-lockfile
yarn add process-lockfile
bun add process-lockfile
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2017-11-16 |
| First published | 2017-11-16 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 3 |
| Author | steelbrain |
| Maintainers | steelbrain |

## Links

- npm: https://www.npmjs.com/package/process-lockfile
- Repository: https://github.com/steelbrain/process-lockfile
- Homepage: https://github.com/steelbrain/process-lockfile#readme
- Issues: https://github.com/steelbrain/process-lockfile/issues
- npm.io page: https://npm.io/package/process-lockfile

## Dependencies (1)

- [sb-promisify](https://npm.io/package/sb-promisify.md) ^2.0.2

## Recent versions

- 1.0.1 (latest) — 2017-11-16
- 1.0.0 — 2017-11-16

## README

Process Lockfile
===========

[![Greenkeeper badge](https://badges.greenkeeper.io/steelbrain/process-lockfile.svg)](https://greenkeeper.io/)

Lockfiles for Node.js with extended capabilities

## Installation

```
npm install --save process-lockfile
```

## API

```js
export async function isLocked(path: string): Promise<boolean>
export function isLockedSync(path: string): boolean

export async function unlock(path: string) {
export function unlockSync(path: string)

export async function lock(path: string)
export function lockSync(path: string)

export async function releaseAllLocks()
export function releaseAllLocksSync()

export function getLockedFiles(): Array<string>
```

## Usage

**Note:** This package does not automatically unlock the files on process exit, so you might want to release all locks on process exit or term

```js
import { lock, isLocked, releaseAllLocksSync } from 'process-lockfile'

async function main() {
  const lockFile = './some-path-for-lockfile'

  if (await isLocked(lockFile)) {
    throw new Error('Lockfile exists at ' + lockFile)
  }
  ['SIGINT', 'SIGTERM'].forEach(event =>
    process.once(event, releaseAllLocksSync),
  )
  await lock(lockFile)
  // .. do your work here
}
```

## License
This project is licensed under the terms of MIT License. See the License file for more info.

---
_Source: https://npm.io/package/process-lockfile · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
