Skip to content

Commit

Permalink
better method
Browse files Browse the repository at this point in the history
  • Loading branch information
kaizencc committed Nov 18, 2024
1 parent 5c078b8 commit 85a60fd
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions packages/aws-cdk/lib/api/garbage-collection/garbage-collector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -723,12 +723,15 @@ export class GarbageCollector {
}

private async confirmationPrompt(printer: ProgressPrinter, deletables: GcAsset[], type: string) {
const pluralize = (name: string, count: number): string => {
return count === 1 ? name : `${name}s`;
}

if (this.confirm) {
const typeName = `${type}${deletables.length === 1 ? '' : 's'}`;
const message = [
`Found ${deletables.length} ${typeName} to delete based off of the following criteria:`,
`- ${typeName} have been isolated for > ${this.props.rollbackBufferDays} days`,
`- ${typeName} were created > ${this.props.createdBufferDays} days ago`,
`Found ${deletables.length} ${pluralize(type, deletables.length)} to delete based off of the following criteria:`,
`- ${type}s have been isolated for > ${this.props.rollbackBufferDays} days`,
`- ${type}s were created > ${this.props.createdBufferDays} days ago`,
'',
'Delete this batch (yes/no/delete-all)?',
].join('\n');
Expand Down

0 comments on commit 85a60fd

Please sign in to comment.