Skip to content

Commit c35673e

Browse files
authored
fix: hooks not being called (#5729)
closes NativeScript/nativescript-app-templates#227
1 parent 2ea02f3 commit c35673e

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

lib/common/services/hooks-service.ts

+9-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import {
2020
} from "../../definitions/project";
2121
import { IInjector } from "../definitions/yok";
2222
import { injector } from "../yok";
23-
import { cache } from "../decorators";
23+
import { memoize } from "../decorators";
2424

2525
class Hook implements IHook {
2626
constructor(public name: string, public fullPath: string) {}
@@ -51,7 +51,14 @@ export class HooksService implements IHooksService {
5151
return "hookArgs";
5252
}
5353

54-
@cache()
54+
@memoize({
55+
shouldCache() {
56+
// only cache if we have hooks directories, the only case to
57+
// not have hooks directories is when the project dir is
58+
// not set yet, ie. when creating a project.
59+
return !!this.hooksDirectories.length;
60+
},
61+
})
5562
private initialize(projectDir: string): void {
5663
this.cachedHooks = {};
5764

0 commit comments

Comments
 (0)