
This change does not alter the current behavior, but makes it easier to introduce `TaskQueue`s implementing different task selection algorithms, for example to support executing multiple tasks in parallel (while respecting interdependencies between them). Inspired by/Based on @alxhub's prototype: alxhub/angular@cb631bdb1 PR Close #32427
39 lines
1.4 KiB
TypeScript
39 lines
1.4 KiB
TypeScript
/**
|
|
* @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 {resolve} from '../../../src/ngtsc/file_system';
|
|
import {markAsProcessed} from '../packages/build_marker';
|
|
import {PackageJsonFormatProperties} from '../packages/entry_point';
|
|
import {PackageJsonUpdater} from '../writing/package_json_updater';
|
|
|
|
import {Task, TaskProcessingOutcome} from './api';
|
|
|
|
|
|
/** A helper function for handling a task's being completed. */
|
|
export const onTaskCompleted =
|
|
(pkgJsonUpdater: PackageJsonUpdater, task: Task, outcome: TaskProcessingOutcome): void => {
|
|
const {entryPoint, formatPropertiesToMarkAsProcessed, processDts} = task;
|
|
|
|
if (outcome === TaskProcessingOutcome.Processed) {
|
|
const packageJsonPath = resolve(entryPoint.path, 'package.json');
|
|
const propsToMarkAsProcessed: PackageJsonFormatProperties[] =
|
|
[...formatPropertiesToMarkAsProcessed];
|
|
|
|
if (processDts) {
|
|
propsToMarkAsProcessed.push('typings');
|
|
}
|
|
|
|
markAsProcessed(
|
|
pkgJsonUpdater, entryPoint.packageJson, packageJsonPath, propsToMarkAsProcessed);
|
|
}
|
|
};
|
|
|
|
/** Stringify a task for debugging purposes. */
|
|
export const stringifyTask = (task: Task): string =>
|
|
`{entryPoint: ${task.entryPoint.name}, formatProperty: ${task.formatProperty}, processDts: ${task.processDts}}`;
|