From 92c902a406c036e79a82fb9c5d7e1444d4af1527 Mon Sep 17 00:00:00 2001 From: Igor Randjelovic Date: Wed, 12 Apr 2023 10:34:44 +0200 Subject: [PATCH] fix: hooks not being called closes https://github.com/NativeScript/nativescript-app-templates/pull/227 --- lib/common/services/hooks-service.ts | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/common/services/hooks-service.ts b/lib/common/services/hooks-service.ts index 95756a592b..4113efeebd 100644 --- a/lib/common/services/hooks-service.ts +++ b/lib/common/services/hooks-service.ts @@ -20,7 +20,7 @@ import { } from "../../definitions/project"; import { IInjector } from "../definitions/yok"; import { injector } from "../yok"; -import { cache } from "../decorators"; +import { memoize } from "../decorators"; class Hook implements IHook { constructor(public name: string, public fullPath: string) {} @@ -51,7 +51,14 @@ export class HooksService implements IHooksService { return "hookArgs"; } - @cache() + @memoize({ + shouldCache() { + // only cache if we have hooks directories, the only case to + // not have hooks directories is when the project dir is + // not set yet, ie. when creating a project. + return !!this.hooksDirectories.length; + }, + }) private initialize(projectDir: string): void { this.cachedHooks = {};