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

Commit

Permalink
feat: default for prompt
Browse files Browse the repository at this point in the history
  • Loading branch information
jdx committed May 6, 2018
1 parent b136fce commit bb4c363
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 4 additions & 1 deletion examples/prompt.ts
Original file line number Diff line number Diff line change
@@ -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')
Expand All @@ -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}`)
}
Expand Down
2 changes: 1 addition & 1 deletion test/prompt.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})
})

0 comments on commit bb4c363

Please sign in to comment.