Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "@microsoft/rush",
"comment": "Fix to allow Bridge Cache plugin be installed but not used when build cache disabled; add cache key to terminal logs",
"type": "none"
}
],
"packageName": "@microsoft/rush"
}
12 changes: 8 additions & 4 deletions rush-plugins/rush-bridge-cache-plugin/src/BridgeCachePlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,16 +83,17 @@ export class BridgeCachePlugin implements IRushPlugin {
): Promise<void> => {
const { buildCacheConfiguration } = context;
const { terminal } = logger;

if (cacheAction === undefined) {
return;
}

if (!buildCacheConfiguration?.buildCacheEnabled) {
throw new Error(
`The build cache must be enabled to use the "${this._actionParameterName}" parameter.`
);
}

if (cacheAction === undefined) {
return;
}

const filteredOperations: Set<IOperationExecutionResult> = new Set();
for (const operationExecutionResult of recordByOperation.values()) {
if (!operationExecutionResult.operation.isNoOp) {
Expand Down Expand Up @@ -122,6 +123,7 @@ export class BridgeCachePlugin implements IRushPlugin {
terminal.writeLine(
`Operation "${operation.name}": Outputs have been restored from the build cache."`
);
terminal.writeLine(`Cache key: ${projectBuildCache.cacheId}`);
} else {
terminal.writeWarningLine(
`Operation "${operation.name}": Outputs could not be restored from the build cache.`
Expand Down Expand Up @@ -155,6 +157,7 @@ export class BridgeCachePlugin implements IRushPlugin {
terminal.writeLine(
`Operation "${operation.name}": Existing outputs have been successfully written to the build cache."`
);
terminal.writeLine(`Cache key: ${projectBuildCache.cacheId}`);
} else {
terminal.writeErrorLine(
`Operation "${operation.name}": An error occurred while writing existing outputs to the build cache.`
Expand All @@ -179,6 +182,7 @@ export class BridgeCachePlugin implements IRushPlugin {
const cacheActionParameter: CommandLineParameter | undefined = context.customParameters.get(
this._actionParameterName
);

if (cacheActionParameter) {
if (cacheActionParameter.kind !== CommandLineParameterKind.Choice) {
throw new Error(
Expand Down
Loading