forked from microsoft/rushstack
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPhaseAction.ts
More file actions
53 lines (44 loc) · 1.92 KB
/
PhaseAction.ts
File metadata and controls
53 lines (44 loc) · 1.92 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
// See LICENSE in the project root for license information.
import { CommandLineAction } from '@rushstack/ts-command-line';
import { HeftActionRunner } from '../HeftActionRunner';
import { Selection } from '../../utilities/Selection';
import type { IHeftAction, IHeftActionOptions } from './IHeftAction';
import type { HeftPhase } from '../../pluginFramework/HeftPhase';
export interface IPhaseActionOptions extends IHeftActionOptions {
phase: HeftPhase;
}
export class PhaseAction extends CommandLineAction implements IHeftAction {
public readonly watch: boolean;
private readonly _actionRunner: HeftActionRunner;
private readonly _phase: HeftPhase;
private _selectedPhases: Set<HeftPhase> | undefined;
public constructor(options: IPhaseActionOptions) {
super({
actionName: `${options.phase.phaseName}${options.watch ? '-watch' : ''}`,
documentation:
`Runs to the ${options.phase.phaseName} phase, including all transitive dependencies` +
(options.watch ? ', in watch mode.' : '.') +
(options.phase.phaseDescription ? ` ${options.phase.phaseDescription}` : ''),
summary:
`Runs to the ${options.phase.phaseName} phase, including all transitive dependencies` +
(options.watch ? ', in watch mode.' : '.')
});
this.watch = options.watch ?? false;
this._phase = options.phase;
this._actionRunner = new HeftActionRunner({ action: this, ...options });
this._actionRunner.defineParameters();
}
public get selectedPhases(): ReadonlySet<HeftPhase> {
if (!this._selectedPhases) {
this._selectedPhases = Selection.recursiveExpand(
[this._phase],
(phase: HeftPhase) => phase.dependencyPhases
);
}
return this._selectedPhases;
}
protected override async onExecuteAsync(): Promise<void> {
await this._actionRunner.executeAsync();
}
}