knifecycle
Advanced tools
Comparing version 2.6.1 to 2.6.2
@@ -0,1 +1,11 @@ | ||
<a name="2.6.2"></a> | ||
## [2.6.2](https://github.com/nfroidure/knifecycle/compare/v2.6.1...v2.6.2) (2018-09-30) | ||
### Bug Fixes | ||
* **$autoload:** Fix autoload disposal ([f087b12](https://github.com/nfroidure/knifecycle/commit/f087b12)) | ||
<a name="2.6.1"></a> | ||
@@ -2,0 +12,0 @@ ## [2.6.1](https://github.com/nfroidure/knifecycle/compare/v2.6.0...v2.6.1) (2018-09-30) |
@@ -521,41 +521,48 @@ "use strict"; | ||
yield Promise.all(reversedServiceSequence.pop().map(serviceName => { | ||
const singletonServiceDescriptor = _this._singletonsServicesDescriptors.get(serviceName); | ||
yield Promise.all(reversedServiceSequence.pop().map( | ||
/*#__PURE__*/ | ||
function () { | ||
var _ref2 = _asyncToGenerator(function* (serviceName) { | ||
const singletonServiceDescriptor = yield _this._singletonsServicesDescriptors.get(serviceName); | ||
const serviceDescriptor = singletonServiceDescriptor || (yield siloContext.servicesDescriptors.get(serviceName)); | ||
let serviceShutdownPromise = _this._singletonsServicesShutdownsPromises.get(serviceName) || siloContext.servicesShutdownsPromises.get(serviceName); | ||
const serviceDescriptor = singletonServiceDescriptor || siloContext.servicesDescriptors.get(serviceName); | ||
let serviceShutdownPromise = _this._singletonsServicesShutdownsPromises.get(serviceName) || siloContext.servicesShutdownsPromises.get(serviceName); | ||
if (serviceShutdownPromise) { | ||
debug('Reusing a service shutdown promise:', serviceName); | ||
return serviceShutdownPromise; | ||
} | ||
if (serviceShutdownPromise) { | ||
debug('Reusing a service shutdown promise:', serviceName); | ||
return serviceShutdownPromise; | ||
} | ||
if (reversedServiceSequence.some(servicesDeclarations => servicesDeclarations.includes(serviceName))) { | ||
debug('Delaying service shutdown:', serviceName); | ||
return Promise.resolve(); | ||
} | ||
if (reversedServiceSequence.some(servicesDeclarations => servicesDeclarations.includes(serviceName))) { | ||
debug('Delaying service shutdown:', serviceName); | ||
return Promise.resolve(); | ||
} | ||
if (singletonServiceDescriptor) { | ||
const handleSet = _this._singletonsServicesHandles.get(serviceName); | ||
if (singletonServiceDescriptor) { | ||
const handleSet = _this._singletonsServicesHandles.get(serviceName); | ||
handleSet.delete(siloContext.name); | ||
handleSet.delete(siloContext.name); | ||
if (handleSet.size) { | ||
debug('Singleton is used elsewhere:', serviceName, handleSet); | ||
return Promise.resolve(); | ||
} | ||
if (handleSet.size) { | ||
debug('Singleton is used elsewhere:', serviceName, handleSet); | ||
return Promise.resolve(); | ||
_this._singletonsServicesDescriptors.delete(serviceName); | ||
} | ||
_this._singletonsServicesDescriptors.delete(serviceName); | ||
} | ||
debug('Shutting down a service:', serviceName); | ||
serviceShutdownPromise = serviceDescriptor.dispose ? serviceDescriptor.dispose() : Promise.resolve(); | ||
debug('Shutting down a service:', serviceName); | ||
serviceShutdownPromise = serviceDescriptor.dispose ? serviceDescriptor.dispose() : Promise.resolve(); | ||
if (singletonServiceDescriptor) { | ||
_this._singletonsServicesShutdownsPromises.set(serviceName, serviceShutdownPromise); | ||
} | ||
if (singletonServiceDescriptor) { | ||
_this._singletonsServicesShutdownsPromises.set(serviceName, serviceShutdownPromise); | ||
} | ||
siloContext.servicesShutdownsPromises.set(serviceName, serviceShutdownPromise); | ||
return serviceShutdownPromise; | ||
}); | ||
siloContext.servicesShutdownsPromises.set(serviceName, serviceShutdownPromise); | ||
return serviceShutdownPromise; | ||
})); | ||
return function (_x2) { | ||
return _ref2.apply(this, arguments); | ||
}; | ||
}())); | ||
yield _shutdownNextServices(reversedServiceSequence); | ||
@@ -660,2 +667,7 @@ }); | ||
siloContext.servicesDescriptors.set(serviceName, serviceDescriptorPromise); | ||
} // Since the autoloader is a bit special it must be pushed here | ||
if (AUTOLOAD === _this3.serviceName) { | ||
siloContext.servicesSequence.unshift([AUTOLOAD]); | ||
} | ||
@@ -842,3 +854,3 @@ | ||
function () { | ||
var _ref3 = _asyncToGenerator(function* (serviceDeclaration) { | ||
var _ref4 = _asyncToGenerator(function* (serviceDeclaration) { | ||
const { | ||
@@ -864,15 +876,23 @@ mappedName, | ||
return function (_x2) { | ||
return _ref3.apply(this, arguments); | ||
return function (_x3) { | ||
return _ref4.apply(this, arguments); | ||
}; | ||
}())); | ||
debug('Initialized dependencies descriptors:', serviceName, servicesDeclarations, servicesDescriptors); | ||
siloContext.servicesSequence.push(servicesDeclarations.map(_pickMappedNameFromDeclaration)); | ||
const services = yield Promise.all(servicesDescriptors.map(serviceDescriptor => { | ||
if (!serviceDescriptor) { | ||
return {}.undef; | ||
} | ||
siloContext.servicesSequence.push(servicesDeclarations.filter((_, index) => servicesDescriptors[index]).map(_pickMappedNameFromDeclaration)); | ||
const services = yield Promise.all(servicesDescriptors.map( | ||
/*#__PURE__*/ | ||
function () { | ||
var _ref5 = _asyncToGenerator(function* (serviceDescriptor) { | ||
if (!serviceDescriptor) { | ||
return {}.undef; | ||
} | ||
return serviceDescriptor.service; | ||
})); | ||
return serviceDescriptor.service; | ||
}); | ||
return function (_x4) { | ||
return _ref5.apply(this, arguments); | ||
}; | ||
}())); | ||
return services.reduce((hash, service, index) => { | ||
@@ -879,0 +899,0 @@ const mappedName = _pickMappedNameFromDeclaration(servicesDeclarations[index]); |
{ | ||
"name": "knifecycle", | ||
"version": "2.6.1", | ||
"version": "2.6.2", | ||
"description": "Manage your NodeJS processes's lifecycle.", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -560,4 +560,4 @@ /* eslint max-len: ["warn", { "ignoreComments": true }] */ | ||
await Promise.all( | ||
reversedServiceSequence.pop().map(serviceName => { | ||
const singletonServiceDescriptor = _this._singletonsServicesDescriptors.get( | ||
reversedServiceSequence.pop().map(async serviceName => { | ||
const singletonServiceDescriptor = await _this._singletonsServicesDescriptors.get( | ||
serviceName, | ||
@@ -567,3 +567,3 @@ ); | ||
singletonServiceDescriptor || | ||
siloContext.servicesDescriptors.get(serviceName); | ||
(await siloContext.servicesDescriptors.get(serviceName)); | ||
let serviceShutdownPromise = | ||
@@ -726,2 +726,6 @@ _this._singletonsServicesShutdownsPromises.get(serviceName) || | ||
} | ||
// Since the autoloader is a bit special it must be pushed here | ||
if (AUTOLOAD === this.serviceName) { | ||
siloContext.servicesSequence.unshift([AUTOLOAD]); | ||
} | ||
return serviceDescriptorPromise; | ||
@@ -936,7 +940,9 @@ } | ||
siloContext.servicesSequence.push( | ||
servicesDeclarations.map(_pickMappedNameFromDeclaration), | ||
servicesDeclarations | ||
.filter((_, index) => servicesDescriptors[index]) | ||
.map(_pickMappedNameFromDeclaration), | ||
); | ||
const services = await Promise.all( | ||
servicesDescriptors.map(serviceDescriptor => { | ||
servicesDescriptors.map(async serviceDescriptor => { | ||
if (!serviceDescriptor) { | ||
@@ -943,0 +949,0 @@ return {}.undef; |
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
Unpopular package
QualityThis package is not very popular.
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
263756
6005
685
1
101
1
1
3