@jacobbubu/pidfile
v1.0.0
Published
[](https://github.com/jacobbubu/pidfile/actions?query=workflow%3A%22Build+and+Release%22) [
Usage
import * as path from 'path'
import { promises as fs } from 'fs'
import pidlock from '@jacobbubu/pidfile'
const main = async () => {
const filename = path.join(__dirname, 'lock.pid')
const unlock = await pidlock(path.join(__dirname, 'lock.pid'), { unlockOnExit: false })
if (unlock instanceof Error) {
// unlock is an Error object withe message 'Lockfile already acquired'
} else {
const pid = await fs.readFile(filename, 'utf8')
console.log({ pidInFile: pid, pid: process.pid })
unlock()
}
}
main()Before push
Before pushing the code to GitHub, please make sure that NPM_TOKEN is configured in https://github.com/__your_repo__/settings/secrets, or you can do this through semantic-release-cli.
