proper-lockfile
Advanced tools
Comparing version 3.1.0 to 3.2.0
@@ -5,2 +5,12 @@ # Change Log | ||
<a name="3.2.0"></a> | ||
# [3.2.0](https://github.com/moxystudio/node-proper-lockfile/compare/v3.1.0...v3.2.0) (2018-11-19) | ||
### Features | ||
* add lock path option ([#66](https://github.com/moxystudio/node-proper-lockfile/issues/66)) ([32f1b8d](https://github.com/moxystudio/node-proper-lockfile/commit/32f1b8d)) | ||
<a name="3.1.0"></a> | ||
@@ -7,0 +17,0 @@ # [3.1.0](https://github.com/moxystudio/node-proper-lockfile/compare/v3.0.2...v3.1.0) (2018-11-15) |
@@ -10,4 +10,4 @@ 'use strict'; | ||
function getLockFile(file) { | ||
return `${file}.lock`; | ||
function getLockFile(file, options) { | ||
return options.lockfilePath || `${file}.lock`; | ||
} | ||
@@ -27,3 +27,3 @@ | ||
// Use mkdir to create the lockfile (atomic operation) | ||
options.fs.mkdir(getLockFile(file), (err) => { | ||
options.fs.mkdir(getLockFile(file, options), (err) => { | ||
// If successful, we are done | ||
@@ -44,3 +44,3 @@ if (!err) { | ||
options.fs.stat(getLockFile(file), (err, stat) => { | ||
options.fs.stat(getLockFile(file, options), (err, stat) => { | ||
if (err) { | ||
@@ -79,3 +79,3 @@ // Retry if the lockfile has been removed (meanwhile) | ||
// Remove lockfile, ignoring ENOENT errors | ||
options.fs.rmdir(getLockFile(file), (err) => { | ||
options.fs.rmdir(getLockFile(file, options), (err) => { | ||
if (err && err.code !== 'ENOENT') { | ||
@@ -104,3 +104,3 @@ return callback(err); | ||
options.fs.utimes(getLockFile(file), mtime, mtime, (err) => { | ||
options.fs.utimes(getLockFile(file, options), mtime, mtime, (err) => { | ||
// Ignore if the lock was released | ||
@@ -283,3 +283,3 @@ if (lock.released) { | ||
// Check if lockfile exists | ||
options.fs.stat(getLockFile(file), (err, stat) => { | ||
options.fs.stat(getLockFile(file, options), (err, stat) => { | ||
if (err) { | ||
@@ -304,3 +304,5 @@ // If does not exist, file is not locked. Otherwise, callback with error | ||
for (const file in locks) { | ||
try { locks[file].options.fs.rmdirSync(getLockFile(file)); } catch (e) { /* Empty */ } | ||
const options = locks[file].options; | ||
try { options.fs.rmdirSync(getLockFile(file, options)); } catch (e) { /* Empty */ } | ||
} | ||
@@ -307,0 +309,0 @@ }); |
{ | ||
"name": "proper-lockfile", | ||
"version": "3.1.0", | ||
"version": "3.2.0", | ||
"description": "A inter-process and inter-machine lockfile utility that works on a local or network file system", | ||
@@ -28,5 +28,3 @@ "keywords": [ | ||
"prerelease": "npm t && npm run lint", | ||
"release": "standard-version", | ||
"precommit": "lint-staged", | ||
"commitmsg": "commitlint -e $GIT_PARAMS" | ||
"release": "standard-version" | ||
}, | ||
@@ -38,2 +36,8 @@ "standard-version": { | ||
}, | ||
"husky": { | ||
"hooks": { | ||
"commit-msg": "commitlint -E HUSKY_GIT_PARAMS", | ||
"pre-commit": "lint-staged" | ||
} | ||
}, | ||
"lint-staged": { | ||
@@ -59,9 +63,9 @@ "*.js": [ | ||
"@segment/clear-timeouts": "^2.0.0", | ||
"delay": "^3.0.0", | ||
"delay": "^4.1.0", | ||
"eslint": "^5.3.0", | ||
"eslint-config-moxy": "^6.0.1", | ||
"execa": "^0.10.0", | ||
"husky": "^0.14.3", | ||
"execa": "^1.0.0", | ||
"husky": "^1.1.4", | ||
"jest": "^23.4.2", | ||
"lint-staged": "^7.0.0", | ||
"lint-staged": "^8.0.4", | ||
"mkdirp": "^0.5.1", | ||
@@ -68,0 +72,0 @@ "p-defer": "^1.0.0", |
@@ -49,3 +49,5 @@ # proper-lockfile | ||
- It has a default value of `0` for the stale option which isn't good because any crash or process kill that the package can't handle gracefully will leave the lock active forever. | ||
### Compromised | ||
@@ -83,2 +85,3 @@ | ||
- `onCompromised`: Called if the lock gets compromised, defaults to a function that simply throws the error which will probably cause the process to die | ||
- `lockfilePath`: Custom lockfile path. e.g.: If you want to lock a directory and create the lock file inside it, you can pass `file` as `<dir path>` and `options.lockfilePath` as `<dir path>/dir.lock` | ||
@@ -112,2 +115,3 @@ | ||
- `fs`: A custom fs to use, defaults to `graceful-fs` | ||
- `lockfilePath`: Custom lockfile path. e.g.: If you want to lock a directory and create the lock file inside it, you can pass `file` as `<dir path>` and `options.lockfilePath` as `<dir path>/dir.lock` | ||
@@ -136,2 +140,3 @@ | ||
- `fs`: A custom fs to use, defaults to `graceful-fs` | ||
- `lockfilePath`: Custom lockfile path. e.g.: If you want to lock a directory and create the lock file inside it, you can pass `file` as `<dir path>` and `options.lockfilePath` as `<dir path>/dir.lock` | ||
@@ -166,3 +171,3 @@ | ||
`proper-lockfile` automatically remove locks if the process exists. | ||
`proper-lockfile` automatically remove locks if the process exists, except if the process is killed with SIGKILL or it crashes due to a VM fatal error (e.g.: out of memory). | ||
@@ -169,0 +174,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
24725
343
181
0