MCPcopy
hub / github.com/rpamis/comet / applyBulkOverwriteChoice

Function applyBulkOverwriteChoice

src/commands/init.ts:141–155  ·  view source on GitHub ↗
(
  plan: T,
  choice: Exclude<BulkOverwriteChoice, 'choose'>,
  hasExisting?: { os?: boolean; sp?: boolean; cm?: boolean },
)

Source from the content-addressed store, hash-verified

139}
140
141function 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
157function resolveAction(
158 hasExisting: boolean,

Callers 2

init.test.tsFile · 0.85
initCommandFunction · 0.85

Calls 1

shouldApplyFunction · 0.85

Tested by

no test coverage detected