Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

dotlockfile

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dotlockfile

dotlockfile for javascript

  • 0.2.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1
Maintainers
1
Weekly downloads
 
Created
Source

Dotlockfile.js

Build Status

The node.js implementation of dotlockfile with some differences

Install

npm i dotlockfile

// ES6
{ create, check, touch } from 'dotlockfile';
async stuff() {
    try {
        const remove = await create(somePath, { pid: process.pid });
        //do stuff
        await remove();
    } catch (e) {
        errorHandler(e);
    }
}

//ES5
const dtf = require('dotlockfile');
dtf.create(somePath, { pid: process.pid }).then(remove => {
    //do stuff
    return remove()
})
.catch(errorHandler);

Known issues

Compatible node v4+ only

Differences

AFAIK:

  • retries (-r) defaults to 0
  • retries (-r) === -1 just won't work, no infinite loop.
  • no -m option (mail)

API

all path parameters defaults to `${process.pid}.lock`

create(path: string[, options: Object]) => Promise

Create a lockfile.

options defaults to:

{
    retries: 0,
    pid: null,
}

Resolves to a function to remove your lock if you acquired the lock.

Rejects to an error with reason in the message if it couldn't create the lock.

remove(path: string): Promise

Remove lockfile.

Resolve if you removed the lock (or lock isn't there).

Rejects if it couldn't remove the lock.

check(path: string): Promise

Check lockfile validity.

Resolves to true if lockfile is valid.

Rejects to an error with invalid lock message if lockfile is invalid (does not automatically remve the lock).

touch(path: string): Promise

Update utime of lockfile

Why this package

I looked for an obvious dotlockfile equivalent and I didn't find it, or I find some stuff but it didn't have obvious tests to show that it's actually working ...

License

MIT

Keywords

FAQs

Package last updated on 22 May 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc