$ cnpm install @pnpm/fs-locker
An fs locker for pnpm
npm i -S @pnpm/fs-locker
'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))
lock(filename, opts) => unlock[.sync]()Locks the specified file. Returns an async and sync unlock function.
filename - the file to lockopts.stale - duration in milliseconds in which the lock is considered staleopts.locks - the folder that contains the lock filesopts.whenLocked - function that is called if a lock is found when trying to create the lockCopyright 2013 - present © cnpmjs.org | Home |