Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run own or immediately extended beforeQueue #1475

Merged
merged 1 commit into from
Sep 25, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 18 additions & 2 deletions src/actions/lifecycle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -371,9 +371,25 @@ export abstract class TasksMixin {
*/
async queueTasks(this: BaseGeneratorImpl): Promise<void> {
const thisAny = this as any;
const thisPrototype = Object.getPrototypeOf(thisAny);

let beforeQueueCallback: (() => Promise<any>) | undefined;
if (this.features.taskPrefix) {
// We want beforeQueue if beforeQueue belongs to the object or to the imediatelly extended class.
beforeQueueCallback =
Object.hasOwn(thisAny, 'beforeQueue') || Object.hasOwn(thisPrototype, 'beforeQueue')
? thisAny.beforeQueue
: undefined;
}

if (!beforeQueueCallback) {
// Fallback to _beforeQueue,
beforeQueueCallback =
Object.hasOwn(thisAny, '_beforeQueue') || Object.hasOwn(thisPrototype, '_beforeQueue')
? thisAny._beforeQueue
: undefined;
}

const beforeQueueCallback: () => Promise<any> =
(this.features.taskPrefix && thisAny.beforeQueue) ?? thisAny._beforeQueue;
if (beforeQueueCallback) {
await beforeQueueCallback.call(this);
}
Expand Down
Loading