@makerdao/services-core
Advanced tools
Comparing version 0.9.5 to 0.9.6
{ | ||
"name": "@makerdao/services-core", | ||
"description": "Dependency injection framework", | ||
"version": "0.9.5", | ||
"version": "0.9.6", | ||
"license": "MIT", | ||
@@ -6,0 +6,0 @@ "main": "dist/index.js", |
@@ -19,2 +19,9 @@ import values from 'lodash.values'; | ||
class ExtractedServiceError extends Error { | ||
constructor(name) { | ||
// prettier-ignore | ||
super('Service with name \'' + name + '\' has been extracted from the core dai.js library into a discrete plugin. Please refer to the documentation here to install and add it to your configuration: \n\n https://github.com/makerdao/dai.js/wiki/Basic-Usage-(Plugins) \n\n'); | ||
} | ||
} | ||
// exported just for testing | ||
@@ -56,2 +63,4 @@ export function orderServices(services) { | ||
service(name, throwIfMissing = true) { | ||
const extractedServices = ['exchange']; | ||
if (!name) { | ||
@@ -61,2 +70,6 @@ throw new Error('Provide a service name.'); | ||
if (!this._services[name] && throwIfMissing && extractedServices.includes(name)) { | ||
throw new ExtractedServiceError(name); | ||
} | ||
if (!this._services[name] && throwIfMissing) { | ||
@@ -115,2 +128,3 @@ throw new ServiceNotFoundError(name); | ||
Container as default, | ||
ExtractedServiceError, | ||
InvalidServiceError, | ||
@@ -117,0 +131,0 @@ ServiceAlreadyRegisteredError, |
import Container, { | ||
ExtractedServiceError, | ||
InvalidServiceError, | ||
@@ -68,2 +69,8 @@ ServiceAlreadyRegisteredError, | ||
test('service() should throw when trying to access an extracted service', () => { | ||
expect(()=> new Container().service('exchange')).toThrow( | ||
ExtractedServiceError.Error | ||
); | ||
}); | ||
test('service() should not throw when a service is not found and throwIfMissing = false', () => { | ||
@@ -70,0 +77,0 @@ expect(new Container().service('IDontExist', false)).toBe(undefined); |
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
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
76911
25
2222
1