@pnpm/fs-locker
TypeScript icon, indicating that this package has built-in type declarations

3.0.1 • Public • Published

@pnpm/fs-locker

An fs locker for pnpm

npm version Build Status

Installation

<pnpm|yarn|npm> add @pnpm/fs-locker

Usage

'use strict'
const lock = require('@pnpm/fs-locker').default
const path = require('path')

const locks = path.resolve('_locks')

lock(process.cwd(), {stale: 100, locks})
  .then(unlock => {
    // do some stuff...
    return unlock() // or unlock.sync()
  })
  .then(() => {
    console.log('folder unlocked')
    //> folder unlocked
  })
  .catch(err => console.error(err))

API

lock(filename, opts) => unlock[.sync]()

Locks the specified file. Returns an async and sync unlock function.

Arguments

  • filename - the file to lock
  • opts.stale - duration in milliseconds in which the lock is considered stale
  • opts.locks - the folder that contains the lock files
  • opts.whenLocked - function that is called if a lock is found when trying to create the lock

License

MIT © Zoltan Kochan

Readme

Keywords

Package Sidebar

Install

npm i @pnpm/fs-locker

Weekly Downloads

52

Version

3.0.1

License

MIT

Unpacked Size

7.27 kB

Total Files

6

Last publish

Collaborators

  • pnpmuser
  • zkochan