mongodb-memory-server
Advanced tools
Comparing version 1.2.0 to 1.3.0
@@ -23,4 +23,14 @@ 'use strict'; | ||
var _properLockfile = require('proper-lockfile'); | ||
var _properLockfile2 = _interopRequireDefault(_properLockfile); | ||
var _mkdirp = require('mkdirp'); | ||
var _mkdirp2 = _interopRequireDefault(_mkdirp); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; } | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
@@ -35,37 +45,78 @@ | ||
key: 'getPath', | ||
value: function getPath() { | ||
var _this = this; | ||
value: function () { | ||
var _ref = _asyncToGenerator(regeneratorRuntime.mark(function _callee() { | ||
var _this = this; | ||
var opts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; | ||
var _opts$downloadDir = opts.downloadDir, | ||
downloadDir = _opts$downloadDir === undefined ? _path2.default.resolve(_os2.default.homedir(), '.mongodb-binaries') : _opts$downloadDir, | ||
_opts$platform = opts.platform, | ||
platform = _opts$platform === undefined ? _os2.default.platform() : _opts$platform, | ||
_opts$arch = opts.arch, | ||
arch = _opts$arch === undefined ? _os2.default.arch() : _opts$arch, | ||
_opts$version = opts.version, | ||
version = _opts$version === undefined ? '3.4.4' : _opts$version, | ||
_opts$http = opts.http, | ||
http = _opts$http === undefined ? {} : _opts$http; | ||
var opts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; | ||
var _opts$downloadDir, downloadDir, _opts$platform, platform, _opts$arch, arch, _opts$version, version, _opts$http, http; | ||
if (!this.cache[version]) { | ||
var downloader = new _mongodbDownload.MongoDBDownload({ | ||
downloadDir, | ||
platform, | ||
arch, | ||
version, | ||
http | ||
}); | ||
return regeneratorRuntime.wrap(function _callee$(_context) { | ||
while (1) { | ||
switch (_context.prev = _context.next) { | ||
case 0: | ||
_opts$downloadDir = opts.downloadDir, downloadDir = _opts$downloadDir === undefined ? _path2.default.resolve(_os2.default.homedir(), '.mongodb-binaries') : _opts$downloadDir, _opts$platform = opts.platform, platform = _opts$platform === undefined ? _os2.default.platform() : _opts$platform, _opts$arch = opts.arch, arch = _opts$arch === undefined ? _os2.default.arch() : _opts$arch, _opts$version = opts.version, version = _opts$version === undefined ? '3.4.4' : _opts$version, _opts$http = opts.http, http = _opts$http === undefined ? {} : _opts$http; | ||
if (opts.debug) { | ||
downloader.debug = console.log.bind(null); | ||
} | ||
if (this.cache[version]) { | ||
_context.next = 5; | ||
break; | ||
} | ||
this.cache[version] = downloader.downloadAndExtract().then(function (releaseDir) { | ||
return _this.findBinPath(releaseDir); | ||
}); | ||
_context.next = 4; | ||
return new Promise(function (resolve, reject) { | ||
(0, _mkdirp2.default)(downloadDir, function (err) { | ||
if (err) reject(err);else resolve(); | ||
}); | ||
}); | ||
case 4: | ||
this.cache[version] = new Promise(function (resolve, reject) { | ||
_properLockfile2.default.lock(downloadDir, { | ||
stale: 120000, | ||
// try to get lock every second, give up after 3 minutes | ||
retries: { retries: 180, factor: 1, minTimeout: 1000 } | ||
}, function (err, releaseLock) { | ||
if (err) { | ||
reject(err); | ||
return; | ||
} | ||
var downloader = new _mongodbDownload.MongoDBDownload({ | ||
downloadDir, | ||
platform, | ||
arch, | ||
version, | ||
http | ||
}); | ||
if (opts.debug) { | ||
downloader.debug = console.log.bind(null); | ||
} | ||
downloader.downloadAndExtract().then(function (releaseDir) { | ||
releaseLock(); | ||
resolve(_this.findBinPath(releaseDir)); | ||
}).catch(function (e) { | ||
return reject(e); | ||
}); | ||
}); | ||
}); | ||
case 5: | ||
return _context.abrupt('return', this.cache[version]); | ||
case 6: | ||
case 'end': | ||
return _context.stop(); | ||
} | ||
} | ||
}, _callee, this); | ||
})); | ||
function getPath() { | ||
return _ref.apply(this, arguments); | ||
} | ||
return this.cache[version]; | ||
} | ||
return getPath; | ||
}() | ||
}, { | ||
@@ -72,0 +123,0 @@ key: 'findBinPath', |
{ | ||
"name": "mongodb-memory-server", | ||
"version": "1.2.0", | ||
"version": "1.3.0", | ||
"description": "In-memory MongoDB Server. Designed with testing in mind, the server will allow you to connect your favourite ODM or client library to the MongoDB Server and run integration tests isolated from each other.", | ||
@@ -52,3 +52,5 @@ "main": "lib/index.js", | ||
"glob": "^7.1.2", | ||
"mkdirp": "^0.5.1", | ||
"mongodb-download": "^2.2.3", | ||
"proper-lockfile": "^2.0.1", | ||
"tmp": "^0.0.31", | ||
@@ -55,0 +57,0 @@ "uuid": "^3.0.1" |
Sorry, the diff of this file is not supported yet
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
53786
673
1
8
+ Addedmkdirp@^0.5.1
+ Addedproper-lockfile@^2.0.1
+ Addedminimist@1.2.8(transitive)
+ Addedmkdirp@0.5.6(transitive)
+ Addedproper-lockfile@2.0.1(transitive)
+ Addedretry@0.10.1(transitive)