refactor(ngcc): abstract onTaskCompleted
out of executors (#36083)
Moving the definition of the `onTaskCompleted` callback into `mainNgcc()` allows it to be configured based on options passed in there more easily. This will be the case when we want to configure whether to log or throw an error for tasks that failed to be processed successfully. This commit also creates two new folders and moves the code around a bit to make it easier to navigate the code§: * `execution/tasks`: specific helpers such as task completion handlers * `execution/tasks/queues`: the `TaskQueue` implementations and helpers PR Close #36083
This commit is contained in:

committed by
Andrew Kushnir

parent
712f2642d5
commit
39d4016fe9
@ -14,6 +14,7 @@ import {AsyncLocker} from '../../locking/async_locker';
|
||||
import {Logger} from '../../logging/logger';
|
||||
import {PackageJsonUpdater} from '../../writing/package_json_updater';
|
||||
import {AnalyzeEntryPointsFn, CreateCompileFn, Executor} from '../api';
|
||||
import {CreateTaskCompletedCallback} from '../tasks/api';
|
||||
|
||||
import {ClusterMaster} from './master';
|
||||
import {ClusterWorker} from './worker';
|
||||
@ -26,7 +27,8 @@ import {ClusterWorker} from './worker';
|
||||
export class ClusterExecutor implements Executor {
|
||||
constructor(
|
||||
private workerCount: number, private logger: Logger,
|
||||
private pkgJsonUpdater: PackageJsonUpdater, private lockFile: AsyncLocker) {}
|
||||
private pkgJsonUpdater: PackageJsonUpdater, private lockFile: AsyncLocker,
|
||||
private createTaskCompletedCallback: CreateTaskCompletedCallback) {}
|
||||
|
||||
async execute(analyzeEntryPoints: AnalyzeEntryPointsFn, createCompileFn: CreateCompileFn):
|
||||
Promise<void> {
|
||||
@ -36,7 +38,8 @@ export class ClusterExecutor implements Executor {
|
||||
this.logger.debug(
|
||||
`Running ngcc on ${this.constructor.name} (using ${this.workerCount} worker processes).`);
|
||||
const master = new ClusterMaster(
|
||||
this.workerCount, this.logger, this.pkgJsonUpdater, analyzeEntryPoints);
|
||||
this.workerCount, this.logger, this.pkgJsonUpdater, analyzeEntryPoints,
|
||||
this.createTaskCompletedCallback);
|
||||
return master.run();
|
||||
});
|
||||
} else {
|
||||
|
Reference in New Issue
Block a user