refactor(ngcc): add message text to task outcomes (#36083)

This sets up the task execution to be able to report failed compiles

PR Close #36083
This commit is contained in:
Pete Bacon Darwin
2020-03-14 13:20:51 +00:00
committed by Andrew Kushnir
parent d50881a86e
commit 712f2642d5
5 changed files with 22 additions and 6 deletions

View File

@ -71,12 +71,15 @@ export interface Task extends JsonObject {
}
/** A function to be called once a task has been processed. */
export type TaskCompletedCallback = (task: Task, outcome: TaskProcessingOutcome) => void;
export type TaskCompletedCallback =
(task: Task, outcome: TaskProcessingOutcome, message: string | null) => void;
/** Represents the outcome of processing a `Task`. */
export const enum TaskProcessingOutcome {
/** Successfully processed the target format property. */
Processed,
/** Failed to process the target format. */
Failed,
}
/**

View File

@ -33,6 +33,7 @@ export interface ProcessTaskMessage extends JsonObject {
export interface TaskCompletedMessage extends JsonObject {
type: 'task-completed';
outcome: TaskProcessingOutcome;
message: string|null;
}
/** A message requesting the update of a `package.json` file. */

View File

@ -30,8 +30,9 @@ export class ClusterWorker {
throw new Error('Tried to instantiate `ClusterWorker` on the master process.');
}
this.compile =
createCompileFn((_task, outcome) => sendMessageToMaster({type: 'task-completed', outcome}));
this.compile = createCompileFn(
(_task, outcome, message) =>
sendMessageToMaster({type: 'task-completed', outcome, message}));
}
run(): Promise<void> {