Skip to content

Commit 28ae1e8

Browse files
committed
patch(refactor): octo hook names simplified.
1 parent 6adde09 commit 28ae1e8

File tree

4 files changed

+20
-20
lines changed

4 files changed

+20
-20
lines changed

packages/octo/src/decorators/enable-hook.decorator.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { AHook } from '../functions/hook/hook.abstract.js';
22
import { Container } from './container.js';
33

4-
type Hook = 'PostModelActionHandleHook' | 'PreCommitHandleHook';
4+
type Hook = 'PostModelActionHook' | 'PreCommitHook';
55

66
export function EnableHook(hook: Hook): (target: any, propertyKey: string, descriptor: PropertyDescriptor) => void {
77
return function (target: any, propertyKey: string, descriptor: PropertyDescriptor) {

packages/octo/src/decorators/module.decorator.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Constructable } from '../app.type.js';
2-
import { PostModelActionCallback, PostModelActionHandleHook } from '../functions/hook/post-model-action-handle.hook.js';
3-
import { PreCommitCallback, PreCommitHandleHook } from '../functions/hook/pre-commit-handle.hook.js';
2+
import { PostModelActionCallback, PostModelActionHook } from '../functions/hook/post-model-action.hook.js';
3+
import { PreCommitCallback, PreCommitHook } from '../functions/hook/pre-commit.hook.js';
44
import { Container } from './container.js';
55

66
export function Module({
@@ -14,7 +14,7 @@ export function Module({
1414
}): (constructor: any) => void {
1515
return function (constructor: any) {
1616
if (postModelActionHandles.length > 0) {
17-
Container.get(PostModelActionHandleHook)
17+
Container.get(PostModelActionHook)
1818
.then((aHook) => {
1919
aHook.register(constructor.name, { imports, postModelActionHandles });
2020
})
@@ -24,7 +24,7 @@ export function Module({
2424
}
2525

2626
if (preCommitHandles.length > 0) {
27-
Container.get(PreCommitHandleHook)
27+
Container.get(PreCommitHook)
2828
.then((aHook) => {
2929
aHook.register(constructor.name, { imports, preCommitHandles });
3030
})

packages/octo/src/functions/hook/post-model-action-handle.hook.ts renamed to packages/octo/src/functions/hook/post-model-action.hook.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { AHook } from './hook.abstract.js';
55

66
export type PostModelActionCallback = (output: ActionOutputs) => Promise<ActionOutputs>;
77

8-
export class PostModelActionHandleHook extends AHook {
8+
export class PostModelActionHook extends AHook {
99
private readonly callbacks: { [key: string]: PostModelActionCallback[] } = {};
1010

1111
private isInstanceOfModelAction(instance: any): instance is IModelAction {
@@ -25,13 +25,13 @@ export class PostModelActionHandleHook extends AHook {
2525

2626
override registrar(constructor: Constructable<unknown>, propertyKey: string, descriptor: PropertyDescriptor): void {
2727
if (!this.isInstanceOfModelAction(constructor.prototype)) {
28-
throw new Error('PostModelActionHandleHook can only be used with ModelAction!');
28+
throw new Error('PostModelActionHook can only be used with ModelAction!');
2929
}
3030

3131
const originalMethod = descriptor.value;
3232
const self = this; // eslint-disable-line @typescript-eslint/no-this-alias
3333

34-
// `self` here references PostModelActionHandleHook, vs `this` references the original method.
34+
// `self` here references this class, vs `this` references the original method.
3535
descriptor.value = async function (...args: any[]): Promise<ActionOutputs> {
3636
let output: ActionOutputs = await originalMethod!.apply(this, args);
3737
for (const callback of self.callbacks[constructor.name] || []) {
@@ -42,13 +42,13 @@ export class PostModelActionHandleHook extends AHook {
4242
}
4343
}
4444

45-
@Factory<PostModelActionHandleHook>(PostModelActionHandleHook)
46-
export class PostModelActionHandleHookFactory {
47-
private static instance: PostModelActionHandleHook;
45+
@Factory<PostModelActionHook>(PostModelActionHook)
46+
export class PostModelActionHookFactory {
47+
private static instance: PostModelActionHook;
4848

49-
static async create(): Promise<PostModelActionHandleHook> {
49+
static async create(): Promise<PostModelActionHook> {
5050
if (!this.instance) {
51-
this.instance = new PostModelActionHandleHook();
51+
this.instance = new PostModelActionHook();
5252
}
5353
return this.instance;
5454
}

packages/octo/src/functions/hook/pre-commit-handle.hook.ts renamed to packages/octo/src/functions/hook/pre-commit.hook.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { AHook } from './hook.abstract.js';
44

55
export type PreCommitCallback = (...args: any[]) => Promise<void>;
66

7-
export class PreCommitHandleHook extends AHook {
7+
export class PreCommitHook extends AHook {
88
private readonly callbacks: PreCommitCallback[] = [];
99

1010
override generateCallbacks(): void {
@@ -19,7 +19,7 @@ export class PreCommitHandleHook extends AHook {
1919
const originalMethod = descriptor.value;
2020
const self = this; // eslint-disable-line @typescript-eslint/no-this-alias
2121

22-
// `self` here references PreCommitHandleHook, vs `this` references the original method.
22+
// `self` here references this class, vs `this` references the original method.
2323
descriptor.value = async function (...args: any[]): Promise<any> {
2424
for (const callback of self.callbacks) {
2525
await callback.apply(this, args);
@@ -30,13 +30,13 @@ export class PreCommitHandleHook extends AHook {
3030
}
3131
}
3232

33-
@Factory<PreCommitHandleHook>(PreCommitHandleHook)
34-
export class PreCommitHandleHookFactory {
35-
private static instance: PreCommitHandleHook;
33+
@Factory<PreCommitHook>(PreCommitHook)
34+
export class PreCommitHookFactory {
35+
private static instance: PreCommitHook;
3636

37-
static async create(): Promise<PreCommitHandleHook> {
37+
static async create(): Promise<PreCommitHook> {
3838
if (!this.instance) {
39-
this.instance = new PreCommitHandleHook();
39+
this.instance = new PreCommitHook();
4040
}
4141
return this.instance;
4242
}

0 commit comments

Comments
 (0)