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

lockfile

Package Overview
Dependencies
Maintainers
2
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

lockfile - npm Package Compare versions

Comparing version 0.4.1 to 0.4.2

14

lockfile.js

@@ -9,2 +9,8 @@ var fs = require('fs')

var os = require('os')
var filetime = 'ctime'
if (os.platform() == "win32") {
filetime = 'mtime'
}
var debug

@@ -90,3 +96,3 @@ var util = require('util')

fs.close(fd, function (er) {
var age = Date.now() - st.ctime.getTime()
var age = Date.now() - st[filetime].getTime()
return cb(er, age <= opts.stale)

@@ -124,3 +130,3 @@ })

}
var age = Date.now() - st.ctime.getTime()
var age = Date.now() - st[filetime].getTime()
return (age <= opts.stale)

@@ -179,3 +185,3 @@ }

var age = Date.now() - st.ctime.getTime()
var age = Date.now() - st[filetime].getTime()
if (age > opts.stale) {

@@ -237,3 +243,3 @@ debug('lock stale', path, opts_)

var st = fs.statSync(path)
var ct = st.ctime.getTime()
var ct = st[filetime].getTime()
if (!(ct % 1000) && (opts.stale % 1000)) {

@@ -240,0 +246,0 @@ // probably don't have subsecond resolution.

{
"name": "lockfile",
"version": "0.4.1",
"version": "0.4.2",
"main": "lockfile.js",

@@ -5,0 +5,0 @@ "directories": {

@@ -16,2 +16,3 @@ var test = require('tap').test

try { lockFile.unlockSync('stale-wait-lock') } catch (er) {}
try { lockFile.unlockSync('stale-windows-lock') } catch (er) {}
t.end()

@@ -253,2 +254,26 @@ })

test('stale windows file tunneling test', function (t) {
// for windows only
// nt file system tunneling feature will make file creation time not updated
var opts = { stale: 1000 }
lockFile.lockSync('stale-windows-lock')
setTimeout(next, 2000)
function next () {
var locked
lockFile.unlockSync('stale-windows-lock')
lockFile.lockSync('stale-windows-lock', opts)
locked = lockFile.checkSync('stale-windows-lock', opts)
t.ok(locked, "should be locked and not stale")
lockFile.lock('stale-windows-lock', opts, function (er) {
if (!er)
t.fail('got second lock? impossible, windows file tunneling problem!')
else
t.pass('second lock failed, windows file tunneling problem fixed')
t.end()
})
}
})
test('cleanup', function (t) {

@@ -263,4 +288,5 @@ try { lockFile.unlockSync('basic-lock') } catch (er) {}

try { lockFile.unlockSync('stale-wait-lock') } catch (er) {}
try { lockFile.unlockSync('stale-windows-lock') } catch (er) {}
t.end()
})
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