fortune-fs
Advanced tools
Comparing version 1.0.1 to 1.0.2
33
index.js
@@ -7,2 +7,3 @@ 'use strict' | ||
var mkdirp = require('mkdirp') | ||
var lockFile = require('lockfile') | ||
@@ -129,14 +130,26 @@ | ||
return new Promise(function (resolve, reject) { | ||
var lockPath | ||
if (record === void 0) return resolve() | ||
return typeof record === 'object' ? | ||
fs.writeFile( | ||
path.join(typeDir, '' + record[primaryKey]), | ||
msgpack.encode(record), | ||
function handle (error) { | ||
return error ? reject(error) : resolve() | ||
}) : | ||
fs.unlink( | ||
path.join(typeDir, '' + record), | ||
resolve) | ||
if (typeof record === 'object') { | ||
lockPath = path.join(typeDir, record[primaryKey] + '.lock') | ||
return lockFile.lock(lockPath, function (error) { | ||
if (error) return reject(error) | ||
fs.writeFile( | ||
path.join(typeDir, '' + record[primaryKey]), | ||
msgpack.encode(record), | ||
function (error) { | ||
if (error) return reject(error) | ||
lockFile.unlock(lockPath, function (error) { | ||
return error ? reject(error) : resolve() | ||
}) | ||
}) | ||
}) | ||
} | ||
fs.unlink(path.join(typeDir, '' + record), resolve) | ||
}) | ||
@@ -143,0 +156,0 @@ })) |
{ | ||
"name": "fortune-fs", | ||
"description": "File system adapter for Fortune.", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"license": "MIT", | ||
@@ -17,2 +17,3 @@ "repository": { | ||
"dependencies": { | ||
"lockfile": "^1.0.2", | ||
"mkdirp": "^0.5.1", | ||
@@ -19,0 +20,0 @@ "msgpack-lite": "^0.1.26" |
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
18159
12
124
3
+ Addedlockfile@^1.0.2
+ Addedlockfile@1.0.4(transitive)
+ Addedsignal-exit@3.0.7(transitive)