diff --git a/examples/prompt.ts b/examples/prompt.ts index ccd95d0e..30faba20 100644 --- a/examples/prompt.ts +++ b/examples/prompt.ts @@ -1,6 +1,6 @@ import {cli} from '../src' -const wait = (ms = 400) => new Promise(resolve => setTimeout(resolve, ms)) +const wait = (ms = 100) => new Promise(resolve => setTimeout(resolve, ms)) async function run() { cli.action.start('doing a thing') @@ -17,6 +17,9 @@ async function run() { cli.log(`you entered: ${input}`) input = await cli.prompt('your name (default)', {default: 'somedefault'}) await wait() + cli.log(`you entered: ${input}`) + input = await cli.prompt('your name (not required)', {required: false}) + await wait() cli.action.stop() cli.log(`you entered: ${input}`) } diff --git a/test/prompt.test.ts b/test/prompt.test.ts index 3b1e5ce3..d6b439b1 100644 --- a/test/prompt.test.ts +++ b/test/prompt.test.ts @@ -25,6 +25,6 @@ describe('prompt', () => { process.stdin.emit('data', '') const answer = await promptPromise await cli.done() - expect(answer).to.equal('') + expect(answer).to.equal(undefined) }) })