@poppinss/hooks
Advanced tools
Comparing version 7.2.1 to 7.2.2
// src/runner.ts | ||
import { debuglog } from "node:util"; | ||
var debug = debuglog("poppinss:hooks"); | ||
var Runner = class { | ||
@@ -48,5 +50,7 @@ constructor(action, hookHandlers) { | ||
if (!handlersToIgnore) { | ||
debug("skipping all hooks"); | ||
this.#skipAllHooks = true; | ||
} else { | ||
this.#skipAllHooks = false; | ||
debug("skipping %O hooks", handlersToIgnore); | ||
this.#handlersToIgnore = handlersToIgnore; | ||
@@ -67,7 +71,14 @@ } | ||
} | ||
debug("running hooks"); | ||
const handlers = reverse ? Array.from(this.#hookHandlers).reverse() : this.#hookHandlers; | ||
for (let handler of handlers) { | ||
if (this.#filter(handler.name)) { | ||
if (handler.name) { | ||
debug("running hook %s", handler.name); | ||
} | ||
const result = await (typeof handler === "function" ? handler(...data) : handler.handle(this.action, ...data)); | ||
if (typeof result === "function") { | ||
if (handler.name) { | ||
debug("cleanup scheduled by %s hook", handler.name); | ||
} | ||
this.#cleanupHandlers.push(result); | ||
@@ -98,2 +109,3 @@ } | ||
this.#state = "cleanup_initiated"; | ||
debug("performing cleanup"); | ||
let startIndex = this.#cleanupHandlers.length; | ||
@@ -100,0 +112,0 @@ while (startIndex--) { |
{ | ||
"name": "@poppinss/hooks", | ||
"version": "7.2.1", | ||
"version": "7.2.2", | ||
"description": "A no brainer hooks module for execute before/after lifecycle hooks", | ||
@@ -33,3 +33,3 @@ "main": "build/index.js", | ||
"sync-labels": "github-label-sync --labels .github/labels.json poppinss/hooks", | ||
"quick:test": "node --loader=ts-node/esm bin/test.ts" | ||
"quick:test": "cross-env NODE_DEBUG=poppinss:hooks node --loader=ts-node/esm bin/test.ts" | ||
}, | ||
@@ -43,22 +43,23 @@ "keywords": [ | ||
"devDependencies": { | ||
"@adonisjs/eslint-config": "^1.1.8", | ||
"@adonisjs/prettier-config": "^1.1.8", | ||
"@adonisjs/tsconfig": "^1.1.8", | ||
"@commitlint/cli": "^18.2.0", | ||
"@commitlint/config-conventional": "^18.1.0", | ||
"@japa/assert": "^2.0.0", | ||
"@adonisjs/eslint-config": "^1.2.0", | ||
"@adonisjs/prettier-config": "^1.2.0", | ||
"@adonisjs/tsconfig": "^1.2.0", | ||
"@commitlint/cli": "^18.4.3", | ||
"@commitlint/config-conventional": "^18.4.3", | ||
"@japa/assert": "^2.0.1", | ||
"@japa/expect-type": "^2.0.0", | ||
"@japa/runner": "^3.0.4", | ||
"@swc/core": "^1.3.96", | ||
"@types/node": "^20.8.10", | ||
"@japa/runner": "^3.1.0", | ||
"@swc/core": "^1.3.100", | ||
"@types/node": "^20.10.4", | ||
"c8": "^8.0.1", | ||
"cross-env": "^7.0.3", | ||
"del-cli": "^5.1.0", | ||
"eslint": "^8.53.0", | ||
"eslint": "^8.55.0", | ||
"github-label-sync": "^2.3.1", | ||
"husky": "^8.0.3", | ||
"np": "^8.0.4", | ||
"prettier": "^3.0.3", | ||
"ts-node": "^10.9.1", | ||
"tsup": "^7.2.0", | ||
"typescript": "^5.2.2" | ||
"np": "^9.2.0", | ||
"prettier": "^3.1.1", | ||
"ts-node": "^10.9.2", | ||
"tsup": "^8.0.1", | ||
"typescript": "^5.3.3" | ||
}, | ||
@@ -65,0 +66,0 @@ "repository": { |
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
28196
300
21