2019-08-19 17:10:09 +03:00
|
|
|
/**
|
|
|
|
|
* @license
|
|
|
|
|
* Copyright Google Inc. All Rights Reserved.
|
|
|
|
|
*
|
|
|
|
|
* Use of this source code is governed by an MIT-style license that can be
|
|
|
|
|
* found in the LICENSE file at https://angular.io/license
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
import {Logger} from '../logging/logger';
|
|
|
|
|
import {PackageJsonUpdater} from '../writing/package_json_updater';
|
|
|
|
|
|
2019-08-29 01:33:15 +03:00
|
|
|
import {AnalyzeEntryPointsFn, CreateCompileFn, Executor} from './api';
|
|
|
|
|
import {onTaskCompleted} from './utils';
|
2019-08-19 17:10:09 +03:00
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* An `Executor` that processes all tasks serially and completes synchronously.
|
|
|
|
|
*/
|
|
|
|
|
export class SingleProcessExecutor implements Executor {
|
|
|
|
|
constructor(private logger: Logger, private pkgJsonUpdater: PackageJsonUpdater) {}
|
|
|
|
|
|
2019-08-29 01:33:15 +03:00
|
|
|
execute(analyzeEntryPoints: AnalyzeEntryPointsFn, createCompileFn: CreateCompileFn): void {
|
2019-08-19 17:10:09 +03:00
|
|
|
this.logger.debug(`Running ngcc on ${this.constructor.name}.`);
|
|
|
|
|
|
|
|
|
|
const {processingMetadataPerEntryPoint, tasks} = analyzeEntryPoints();
|
|
|
|
|
const compile = createCompileFn(
|
|
|
|
|
(task, outcome) =>
|
|
|
|
|
onTaskCompleted(this.pkgJsonUpdater, processingMetadataPerEntryPoint, task, outcome));
|
|
|
|
|
|
|
|
|
|
// Process all tasks.
|
|
|
|
|
for (const task of tasks) {
|
|
|
|
|
compile(task);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-08-19 22:58:22 +03:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* An `Executor` that processes all tasks serially, but still completes asynchronously.
|
|
|
|
|
*/
|
|
|
|
|
export class AsyncSingleProcessExecutor extends SingleProcessExecutor {
|
|
|
|
|
async execute(...args: Parameters<Executor['execute']>): Promise<void> {
|
|
|
|
|
return super.execute(...args);
|
|
|
|
|
}
|
|
|
|
|
}
|