Rush StackShopBlogEvents
Skip to main content

Home > @microsoft/rush-lib > Operation

Operation class

This API is provided as an alpha preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.

The Operation class is a node in the dependency graph of work that needs to be scheduled by the OperationExecutionManager. Each Operation has a runner member of type IOperationRunner, whose implementation manages the actual process of running a single operation.

The graph of Operation instances will be cloned into a separate execution graph after processing.

Signature:

export declare class Operation 

Constructors

Constructor

Modifiers

Description

(constructor)(options)

(ALPHA) Constructs a new instance of the Operation class

Properties

Property

Modifiers

Type

Description

associatedPhase

readonly

IPhase

(ALPHA) The Rush phase associated with this Operation

associatedProject

readonly

RushConfigurationProject

(ALPHA) The Rush project associated with this Operation

consumers

readonly

ReadonlySet<Operation>

(ALPHA) A set of all operations which depend on this operation.

dependencies

readonly

ReadonlySet<Operation>

(ALPHA) A set of all dependencies which must be executed before this operation is complete.

enabled

boolean

(ALPHA) If set to false, this operation will be skipped during evaluation (return OperationStatus.Skipped). This is useful for plugins to alter the scope of the operation graph across executions, e.g. to enable or disable unit test execution, or to include or exclude dependencies.

isNoOp

readonly

boolean

(ALPHA) If set to true, this operation is considered a no-op and can be considered always skipped for analysis purposes.

logFilenameIdentifier

string

(ALPHA) This property is used in the name of the filename for the logs generated by this operation. This is a filesystem-safe version of the phase name. For example, an operation for a phase with name _phase:compile has a logFilenameIdentifier of _phase_compile.

name

readonly

string

(ALPHA) The name of this operation, for logging.

runner

IOperationRunner | undefined

(ALPHA) When the scheduler is ready to process this Operation, the runner implements the actual work of running the operation.

settings

IOperationSettings | undefined

(ALPHA) Get the operation settings for this operation, defaults to the values defined in the project configuration.

weight

number

(ALPHA) The weight for this operation. This scalar is the contribution of this operation to the criticalPathLength calculation above. Modify to indicate the following: - weight === 1: indicates that this operation has an average duration - weight &gt; 1: indicates that this operation takes longer than average and so the scheduler should try to favor starting it over other, shorter operations. An example might be an operation that bundles an entire application and runs whole-program optimization. - weight &lt; 1: indicates that this operation takes less time than average and so the scheduler should favor other, longer operations over it. An example might be an operation to unpack a cached output, or an operation using NullOperationRunner, which might use a value of 0.