({ mode, clack }: ConfirmDeps)
| 16 | ) => Promise<PromptResult<boolean>>; |
| 17 | |
| 18 | export function createConfirm({ mode, clack }: ConfirmDeps): ConfirmFn { |
| 19 | return async (message, opts) => { |
| 20 | if (opts?.yes) return { ok: true, value: true }; |
| 21 | assertHumanMode(mode, "confirm"); |
| 22 | |
| 23 | // Destructive prompts start the cursor on No so a stray Enter is safe. |
| 24 | const value = await clack.confirm( |
| 25 | opts?.destructive ? { message, initialValue: false } : { message }, |
| 26 | ); |
| 27 | if (clack.isCancel(value)) return { ok: false }; |
| 28 | return { ok: true, value }; |
| 29 | }; |
| 30 | } |
no test coverage detected