[READ-ONLY] Mirror of https://github.com/bombshell-dev/clack. Effortlessly build beautiful command-line apps bomb.sh/docs/clack/basics/getting-started/
cli command-line command-line-app node prompt prompts
5

Configure Feed

Select the types of activity you want to include in your feed.

fix(prompts): don't strip dots in spinner stop (#287)

authored by

MacFJA and committed by
GitHub
(Apr 14, 2025, 5:47 PM +0100) 72c2f2d5 dccb07cc

+46 -4
+30
packages/prompts/src/__snapshots__/index.test.ts.snap
··· 1767 1767 ] 1768 1768 `; 1769 1769 1770 + exports[`prompts (isCI = false) > spinner > stop > renders message without removing dots 1`] = ` 1771 + [ 1772 + "[?25l", 1773 + "│ 1774 + ", 1775 + "◒ ", 1776 + "", 1777 + "", 1778 + "◇ foo. 1779 + ", 1780 + "[?25h", 1781 + ] 1782 + `; 1783 + 1770 1784 exports[`prompts (isCI = false) > spinner > stop > renders submit symbol and stops spinner 1`] = ` 1771 1785 [ 1772 1786 "[?25l", ··· 3753 3767 "", 3754 3768 "", 3755 3769 "◇ foo 3770 + ", 3771 + "[?25h", 3772 + ] 3773 + `; 3774 + 3775 + exports[`prompts (isCI = true) > spinner > stop > renders message without removing dots 1`] = ` 3776 + [ 3777 + "[?25l", 3778 + "│ 3779 + ", 3780 + "◒ ...", 3781 + " 3782 + ", 3783 + "", 3784 + "", 3785 + "◇ foo. 3756 3786 ", 3757 3787 "[?25h", 3758 3788 ]
+12
packages/prompts/src/index.test.ts
··· 167 167 168 168 expect(output.buffer).toMatchSnapshot(); 169 169 }); 170 + 171 + test('renders message without removing dots', () => { 172 + const result = prompts.spinner({ output }); 173 + 174 + result.start(); 175 + 176 + vi.advanceTimersByTime(80); 177 + 178 + result.stop('foo.'); 179 + 180 + expect(output.buffer).toMatchSnapshot(); 181 + }); 170 182 }); 171 183 172 184 describe('message', () => {
+4 -4
packages/prompts/src/index.ts
··· 853 853 output.write(erase.down(prevLines.length)); 854 854 }; 855 855 856 - const parseMessage = (msg: string): string => { 856 + const removeTrailingDots = (msg: string): string => { 857 857 return msg.replace(/\.+$/, ''); 858 858 }; 859 859 ··· 867 867 const start = (msg = ''): void => { 868 868 isSpinnerActive = true; 869 869 unblock = block({ output }); 870 - _message = parseMessage(msg); 870 + _message = removeTrailingDots(msg); 871 871 _origin = performance.now(); 872 872 output.write(`${color.gray(S_BAR)}\n`); 873 873 let frameIndex = 0; ··· 905 905 : code === 1 906 906 ? color.red(S_STEP_CANCEL) 907 907 : color.red(S_STEP_ERROR); 908 - _message = parseMessage(msg ?? _message); 908 + _message = msg ?? _message; 909 909 if (indicator === 'timer') { 910 910 output.write(`${step} ${_message} ${formatTimer(_origin)}\n`); 911 911 } else { ··· 916 916 }; 917 917 918 918 const message = (msg = ''): void => { 919 - _message = parseMessage(msg ?? _message); 919 + _message = removeTrailingDots(msg ?? _message); 920 920 }; 921 921 922 922 return {