[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: normalize password prompt empty submit to empty string (#560) (#561)

authored by

Andrew Valleteau and committed by
GitHub
(Jun 15, 2026, 2:26 PM +0100) 2f2b52f7 02ae1919

+22
+5
.changeset/password-empty-submit.md
··· 1 + --- 2 + "@clack/core": patch 3 + --- 4 + 5 + Fix `password` prompt resolving to `undefined` on empty submit. It now normalizes an empty submission to `""`, matching the `text` prompt behavior and the documented `Promise<string | symbol>` return type.
+5
packages/core/src/prompts/password.ts
··· 34 34 this.on('userInput', (input) => { 35 35 this._setValue(input); 36 36 }); 37 + this.on('finalize', () => { 38 + if (this.value === undefined) { 39 + this.value = ''; 40 + } 41 + }); 37 42 } 38 43 }
+12
packages/core/test/prompts/password.test.ts
··· 29 29 expect(output.buffer).to.deep.equal([cursor.hide, 'foo']); 30 30 }); 31 31 32 + test('returns empty string on empty submit', async () => { 33 + const instance = new PasswordPrompt({ 34 + input, 35 + output, 36 + render: () => 'foo', 37 + }); 38 + const resultPromise = instance.prompt(); 39 + input.emit('keypress', '', { name: 'return' }); 40 + const result = await resultPromise; 41 + expect(result).to.equal(''); 42 + }); 43 + 32 44 describe('cursor', () => { 33 45 test('can get cursor', () => { 34 46 const instance = new PasswordPrompt({