All files / infrastructure/scripts/src/shared/adapters prompts.ts

100% Statements 4/4
100% Branches 2/2
100% Functions 1/1
100% Lines 3/3

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12            1x 2x   1x    
import { isCancel, type CANCEL_SYMBOL } from "@clack/prompts";
import { CancelledError } from "../errors.ts";
 
export type Cancellable<T> = T | typeof CANCEL_SYMBOL;
 
/** Convert prompt cancellation into `CancelledError` for `run` to report. */
export const orExit = <T>(value: Cancellable<T>, message: string): T => {
    if (isCancel(value)) throw new CancelledError(message);
 
    return value;
};