(
plan: T,
choice: Exclude<BulkOverwriteChoice, 'choose'>,
hasExisting?: { os?: boolean; sp?: boolean; cm?: boolean },
)
| 139 | } |
| 140 | |
| 141 | function applyBulkOverwriteChoice<T extends ComponentPlan>( |
| 142 | plan: T, |
| 143 | choice: Exclude<BulkOverwriteChoice, 'choose'>, |
| 144 | hasExisting?: { os?: boolean; sp?: boolean; cm?: boolean }, |
| 145 | ): T { |
| 146 | const action = choice === 'overwrite-all' ? 'overwrite' : 'skip'; |
| 147 | const shouldApply = (actionState: ComponentAction, exists?: boolean) => |
| 148 | actionState === 'install' && (hasExisting === undefined || exists === true); |
| 149 | return { |
| 150 | ...plan, |
| 151 | osAction: shouldApply(plan.osAction, hasExisting?.os) ? action : plan.osAction, |
| 152 | spAction: shouldApply(plan.spAction, hasExisting?.sp) ? action : plan.spAction, |
| 153 | cmAction: shouldApply(plan.cmAction, hasExisting?.cm) ? action : plan.cmAction, |
| 154 | }; |
| 155 | } |
| 156 | |
| 157 | function resolveAction( |
| 158 | hasExisting: boolean, |
no test coverage detected