@@ -37,17 +37,17 @@ export abstract class TasksMixin {
37
37
* Register priorities for this generator
38
38
*/
39
39
registerPriorities ( this : BaseGeneratorImpl , priorities : Priority [ ] ) {
40
- priorities = priorities . filter ( priority => {
41
- if ( priority . edit ) {
42
- const queue = this . _queues [ priority . priorityName ] ;
40
+ priorities = priorities . filter ( ( { priorityName , edit , ... priority } ) => {
41
+ if ( edit ) {
42
+ const queue = this . _queues [ priorityName ] ;
43
43
if ( ! queue ) {
44
- throw new Error ( `Error editing priority ${ priority . priorityName } , not found` ) ;
44
+ throw new Error ( `Error editing priority ${ priorityName } , not found` ) ;
45
45
}
46
46
47
47
Object . assign ( queue , { ...priority , edit : undefined } ) ;
48
48
}
49
49
50
- return ! priority . edit ;
50
+ return ! edit ;
51
51
} ) ;
52
52
53
53
const customPriorities = priorities . map ( customPriority => ( { ...customPriority } ) ) ;
@@ -321,21 +321,21 @@ export abstract class TasksMixin {
321
321
async executeTask (
322
322
this : BaseGeneratorImpl ,
323
323
task : Task ,
324
- args = task . args ?? this . args ,
324
+ args = task . args ,
325
325
taskStatus : TaskStatus | undefined = this . _taskStatus ,
326
326
) : Promise < void > {
327
327
const { reject, queueName = 'default' , taskName : methodName , method } = task ;
328
328
const { _namespace : namespace } = this ;
329
- const priority = Object . entries ( this . _queues ) . find ( ( [ _ , options ] ) => ( options as any ) . queueName === queueName ) ;
330
- const priorityName = priority ? priority [ 0 ] : undefined ;
331
329
332
330
debug ( `Running ${ namespace } #${ methodName } ` ) ;
333
331
this . emit ( `method:${ methodName } ` ) ;
334
332
const taskCancelled = task . cancellable && taskStatus ?. cancelled ;
335
333
if ( taskCancelled ) {
336
334
return ;
337
335
}
338
-
336
+ const [ priorityName , priority ] =
337
+ Object . entries ( this . _queues ) . find ( ( [ _ , queue ] ) => queue . queueName === queueName ) ?? [ ] ;
338
+ args ??= priority ?. args ?? this . args ;
339
339
args = typeof args === 'function' ? args ( this as any ) : args ;
340
340
this . runningState = { namespace, queueName, methodName } ;
341
341
try {
0 commit comments