Skip to content
This repository was archived by the owner on Feb 1, 2022. It is now read-only.

Commit bb4c363

Browse files
committed
feat: default for prompt
1 parent b136fce commit bb4c363

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

examples/prompt.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import {cli} from '../src'
22

3-
const wait = (ms = 400) => new Promise(resolve => setTimeout(resolve, ms))
3+
const wait = (ms = 100) => new Promise(resolve => setTimeout(resolve, ms))
44

55
async function run() {
66
cli.action.start('doing a thing')
@@ -17,6 +17,9 @@ async function run() {
1717
cli.log(`you entered: ${input}`)
1818
input = await cli.prompt('your name (default)', {default: 'somedefault'})
1919
await wait()
20+
cli.log(`you entered: ${input}`)
21+
input = await cli.prompt('your name (not required)', {required: false})
22+
await wait()
2023
cli.action.stop()
2124
cli.log(`you entered: ${input}`)
2225
}

test/prompt.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,6 @@ describe('prompt', () => {
2525
process.stdin.emit('data', '')
2626
const answer = await promptPromise
2727
await cli.done()
28-
expect(answer).to.equal('')
28+
expect(answer).to.equal(undefined)
2929
})
3030
})

0 commit comments

Comments
 (0)