knifecycle
Advanced tools
Comparing version 5.3.0 to 6.0.0
@@ -0,1 +1,16 @@ | ||
# [6.0.0](https://github.com/nfroidure/knifecycle/compare/v5.3.0...v6.0.0) (2019-03-15) | ||
### Code Refactoring | ||
* **Chore:** Better handling of optional dependencies ([539eb47](https://github.com/nfroidure/knifecycle/commit/539eb47)) | ||
### BREAKING CHANGES | ||
* **Chore:** Autoloaders needs to throw a E_UNMATCHED_DEPENDENCY error to still work with | ||
optional dependencies | ||
# [5.3.0](https://github.com/nfroidure/knifecycle/compare/v5.2.0...v5.3.0) (2019-03-03) | ||
@@ -2,0 +17,0 @@ |
@@ -854,5 +854,4 @@ "use strict"; | ||
} catch (err) { | ||
// Let pass code errors through to avoid casting | ||
// invalid code to an optional service | ||
if (optional && !(err instanceof SyntaxError) && !(err instanceof TypeError) && !(err instanceof ReferenceError) && !(err instanceof EvalError) && !(err instanceof RangeError)) { | ||
if (optional && ['E_UNMATCHED_DEPENDENCY', E_AUTOLOADER_DYNAMIC_DEPENDENCY].includes(err.code)) { | ||
debug('Optional dependency not found:', serviceDeclaration, err.stack); | ||
return; | ||
@@ -859,0 +858,0 @@ } |
@@ -671,10 +671,16 @@ "use strict"; | ||
} | ||
}, async () => async serviceName => ({ | ||
path: '/path/of/debug', | ||
initializer: (0, _index.initializer)({ | ||
type: 'service', | ||
name: 'hash2', | ||
inject: ['hash3'] | ||
}, async () => 'THE_HASH:' + serviceName) | ||
}))); | ||
}, async () => async serviceName => { | ||
if ('ENV' === serviceName) { | ||
throw new _yerror.default('E_UNMATCHED_DEPENDENCY'); | ||
} | ||
return { | ||
path: '/path/of/debug', | ||
initializer: (0, _index.initializer)({ | ||
type: 'service', | ||
name: 'hash2', | ||
inject: ['hash3'] | ||
}, async () => 'THE_HASH:' + serviceName) | ||
}; | ||
})); | ||
const dependencies = await $.run(['hash', '?ENV']); | ||
@@ -681,0 +687,0 @@ |
{ | ||
"name": "knifecycle", | ||
"version": "5.3.0", | ||
"version": "6.0.0", | ||
"description": "Manage your NodeJS processes's lifecycle automatically with an unobtrusive dependency injection implementation.", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -89,2 +89,3 @@ [//]: # ( ) | ||
import fs from 'fs'; | ||
import YError from 'YError'; | ||
import Knifecycle, { initializer, constant, inject, name } from 'knifecycle'; | ||
@@ -200,3 +201,4 @@ | ||
// DB_URI constant it needs | ||
$.register(constant('DB_URI', 'posgresql://xxxx').register(initDB)); | ||
$.register(constant('DB_URI', 'posgresql://xxxx')); | ||
$.register(initDB); | ||
@@ -241,3 +243,6 @@ // Say we need to use two different DB server | ||
if ('command' !== serviceName) { | ||
throw new Error(`${serviceName} not supported!`); | ||
// Allows to signal that the dependency is not found | ||
// so that optional dependencies doesn't impeach the | ||
// injector to resolve the dependency tree | ||
throw new YError('E_UNMATCHED_DEPENDENCY', serviceName); | ||
} | ||
@@ -244,0 +249,0 @@ try { |
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
215784
3815
1181