(opts: {
isTTY: boolean;
quietOutput: boolean;
startMessage: string;
stopMessage: string;
task: () => Promise<T>;
})
| 110 | } |
| 111 | |
| 112 | async function withSpinner<T>(opts: { |
| 113 | isTTY: boolean; |
| 114 | quietOutput: boolean; |
| 115 | startMessage: string; |
| 116 | stopMessage: string; |
| 117 | task: () => Promise<T>; |
| 118 | }): Promise<T> { |
| 119 | if (!opts.isTTY || opts.quietOutput) { |
| 120 | return opts.task(); |
| 121 | } |
| 122 | |
| 123 | const s = clack.spinner(); |
| 124 | s.start(opts.startMessage); |
| 125 | try { |
| 126 | const result = await opts.task(); |
| 127 | s.stop(opts.stopMessage); |
| 128 | return result; |
| 129 | } catch (error) { |
| 130 | s.stop(opts.startMessage); |
| 131 | throw error; |
| 132 | } |
| 133 | } |
| 134 | |
| 135 | function valuesEqual(left: unknown, right: unknown): boolean { |
| 136 | return JSON.stringify(left) === JSON.stringify(right); |
no test coverage detected