@poppinss/hooks
Advanced tools
Comparing version 1.0.3 to 1.0.4
@@ -16,2 +16,6 @@ import { IocResolverContract } from '@adonisjs/fold'; | ||
/** | ||
* Raise exceptins when resolver is not defined | ||
*/ | ||
private ensureResolver; | ||
/** | ||
* Resolves the hook handler using the resolver when it is defined as string | ||
@@ -18,0 +22,0 @@ * or returns the function reference back |
@@ -28,2 +28,10 @@ "use strict"; | ||
/** | ||
* Raise exceptins when resolver is not defined | ||
*/ | ||
ensureResolver() { | ||
if (!this.resolver) { | ||
throw new Error('IoC container resolver is required to register string based hooks handlers'); | ||
} | ||
} | ||
/** | ||
* Resolves the hook handler using the resolver when it is defined as string | ||
@@ -33,6 +41,4 @@ * or returns the function reference back | ||
resolveHandler(handler) { | ||
if (typeof (handler) === 'string' && !this.resolver) { | ||
throw new Error('Cannot register string based hooks handlers without ioc resolver'); | ||
} | ||
if (typeof (handler) === 'string') { | ||
this.ensureResolver(); | ||
return this.resolver.resolve(handler); | ||
@@ -39,0 +45,0 @@ } |
{ | ||
"name": "@poppinss/hooks", | ||
"version": "1.0.3", | ||
"version": "1.0.4", | ||
"description": "A no brainer hooks module for execute before/after lifecycle hooks", | ||
@@ -12,7 +12,15 @@ "main": "build/index.js", | ||
"dependencies": {}, | ||
"peerDependencies": { | ||
"@adonisjs/fold": "6.x.x" | ||
}, | ||
"peerDependenciesMeta": { | ||
"@adonisjs/fold": { | ||
"optional": true | ||
} | ||
}, | ||
"devDependencies": { | ||
"@adonisjs/fold": "^6.3.1", | ||
"@adonisjs/mrm-preset": "^2.2.4", | ||
"@types/node": "^13.7.0", | ||
"commitizen": "^4.0.3", | ||
"@adonisjs/mrm-preset": "^2.3.0", | ||
"@types/node": "^13.11.1", | ||
"commitizen": "^4.0.4", | ||
"cz-conventional-changelog": "^3.1.0", | ||
@@ -22,12 +30,12 @@ "del-cli": "^3.0.0", | ||
"eslint": "^6.8.0", | ||
"eslint-plugin-adonis": "^1.0.6", | ||
"husky": "^4.2.1", | ||
"eslint-plugin-adonis": "^1.0.9", | ||
"husky": "^4.2.3", | ||
"japa": "^3.0.1", | ||
"mrm": "^2.0.4", | ||
"mrm": "^2.2.0", | ||
"np": "^5.2.1", | ||
"ts-node": "^8.6.2", | ||
"typedoc": "^0.16.9", | ||
"ts-node": "^8.8.2", | ||
"typedoc": "^0.17.4", | ||
"typedoc-plugin-external-module-name": "^3.0.0", | ||
"typedoc-plugin-markdown": "^2.2.16", | ||
"typescript": "^3.7.5" | ||
"typedoc-plugin-markdown": "^2.2.17", | ||
"typescript": "^3.8.3" | ||
}, | ||
@@ -34,0 +42,0 @@ "scripts": { |
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
13264
168
1