Skip to content

Commit f58fc21

Browse files
committed
Use destructuring on rushConfiguration in PhasedScriptAction.
1 parent 7902281 commit f58fc21

1 file changed

Lines changed: 26 additions & 18 deletions

File tree

libraries/rush-lib/src/cli/scriptActions/PhasedScriptAction.ts

Lines changed: 26 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,11 @@ export class PhasedScriptAction extends BaseScriptAction<IPhasedCommandConfig> i
337337
public async runAsync(): Promise<void> {
338338
const stopwatch: Stopwatch = Stopwatch.start();
339339

340+
const {
341+
defaultSubspace,
342+
subspacesFeatureEnabled,
343+
pnpmOptions: { useWorkspaces }
344+
} = this.rushConfiguration;
340345
if (this._alwaysInstall || this._installParameter?.value) {
341346
await measureAsyncFn(`${PERF_PREFIX}:install`, async () => {
342347
const { doBasicInstallAsync } = await import(
@@ -360,7 +365,7 @@ export class PhasedScriptAction extends BaseScriptAction<IPhasedCommandConfig> i
360365
afterInstallAsync: (subspace: Subspace) =>
361366
this.rushSession.hooks.afterInstall.promise(this, subspace, variant),
362367
// Eventually we may want to allow a subspace to be selected here
363-
subspace: this.rushConfiguration.defaultSubspace
368+
subspace: defaultSubspace
364369
});
365370
});
366371
}
@@ -369,14 +374,12 @@ export class PhasedScriptAction extends BaseScriptAction<IPhasedCommandConfig> i
369374
await measureAsyncFn(`${PERF_PREFIX}:checkInstallFlag`, async () => {
370375
// TODO: Replace with last-install.flag when "rush link" and "rush unlink" are removed
371376
const lastLinkFlag: FlagFile = new FlagFile(
372-
this.rushConfiguration.defaultSubspace.getSubspaceTempFolderPath(),
377+
defaultSubspace.getSubspaceTempFolderPath(),
373378
RushConstants.lastLinkFlagFilename,
374379
{}
375380
);
376381
// Only check for a valid link flag when subspaces is not enabled
377-
if (!(await lastLinkFlag.isValidAsync()) && !this.rushConfiguration.subspacesFeatureEnabled) {
378-
const useWorkspaces: boolean =
379-
this.rushConfiguration.pnpmOptions && this.rushConfiguration.pnpmOptions.useWorkspaces;
382+
if (!(await lastLinkFlag.isValidAsync()) && !subspacesFeatureEnabled) {
380383
if (useWorkspaces) {
381384
throw new Error('Link flag invalid.\nDid you run "rush install" or "rush update"?');
382385
} else {
@@ -500,20 +503,27 @@ export class PhasedScriptAction extends BaseScriptAction<IPhasedCommandConfig> i
500503
).IPCOperationRunnerPlugin().apply(this.hooks);
501504
}
502505

506+
const {
507+
experimentsConfiguration: {
508+
configuration: {
509+
buildCacheWithAllowWarningsInSuccessfulBuild = false,
510+
buildSkipWithAllowWarningsInSuccessfulBuild,
511+
omitAppleDoubleFilesFromBuildCache: excludeAppleDoubleFiles = false,
512+
useStreamingBuildCache = false,
513+
usePnpmSyncForInjectedDependencies
514+
}
515+
},
516+
isPnpm
517+
} = this.rushConfiguration;
503518
if (buildCacheConfiguration?.buildCacheEnabled) {
504519
terminal.writeVerboseLine(`Incremental strategy: cache restoration`);
505520
new CacheableOperationPlugin({
506-
allowWarningsInSuccessfulBuild:
507-
!!this.rushConfiguration.experimentsConfiguration.configuration
508-
.buildCacheWithAllowWarningsInSuccessfulBuild,
521+
allowWarningsInSuccessfulBuild: buildCacheWithAllowWarningsInSuccessfulBuild,
509522
buildCacheConfiguration,
510523
cobuildConfiguration,
511524
terminal,
512-
excludeAppleDoubleFiles:
513-
!!this.rushConfiguration.experimentsConfiguration.configuration
514-
.omitAppleDoubleFilesFromBuildCache,
515-
useStreamingBuildCache:
516-
!!this.rushConfiguration.experimentsConfiguration.configuration.useStreamingBuildCache
525+
excludeAppleDoubleFiles,
526+
useStreamingBuildCache
517527
}).apply(this.hooks);
518528

519529
if (this._debugBuildCacheIdsParameter.value) {
@@ -523,9 +533,7 @@ export class PhasedScriptAction extends BaseScriptAction<IPhasedCommandConfig> i
523533
terminal.writeVerboseLine(`Incremental strategy: output preservation`);
524534
// Explicitly disabling the build cache also disables legacy skip detection.
525535
new LegacySkipPlugin({
526-
allowWarningsInSuccessfulBuild:
527-
this.rushConfiguration.experimentsConfiguration.configuration
528-
.buildSkipWithAllowWarningsInSuccessfulBuild,
536+
allowWarningsInSuccessfulBuild: buildSkipWithAllowWarningsInSuccessfulBuild,
529537
terminal,
530538
changedProjectsOnly,
531539
isIncrementalBuildAllowed: this._isIncrementalBuildAllowed
@@ -540,12 +548,12 @@ export class PhasedScriptAction extends BaseScriptAction<IPhasedCommandConfig> i
540548
if (!buildCacheConfiguration?.buildCacheEnabled) {
541549
throw new Error('You must have build cache enabled to use this option.');
542550
}
551+
543552
const { BuildPlanPlugin } = await import('../../logic/operations/BuildPlanPlugin');
544553
new BuildPlanPlugin(terminal).apply(this.hooks);
545554
}
546555

547-
const { configuration: experiments } = this.rushConfiguration.experimentsConfiguration;
548-
if (this.rushConfiguration?.isPnpm && experiments?.usePnpmSyncForInjectedDependencies) {
556+
if (isPnpm && usePnpmSyncForInjectedDependencies) {
549557
const { PnpmSyncCopyOperationPlugin } = await import(
550558
'../../logic/operations/PnpmSyncCopyOperationPlugin'
551559
);

0 commit comments

Comments
 (0)