Skip to content

Commit

Permalink
prompt: add y/N or Y/n if it misses from prompt
Browse files Browse the repository at this point in the history
  • Loading branch information
jaeh committed Apr 25, 2020
1 parent fee7832 commit 715eec1
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/prompt/index.mjs
Expand Up @@ -7,6 +7,18 @@ export const prompt = (msg = '', options = {}) =>
new Promise((resolve, reject) => {
const { yesNo = false, pass = false, std = process, yesDefault = false } = options

if (yesNo) {
if (yesDefault) {
if (!msg.includes('Y/n')) {
msg += '(Y/n): '
}
} else {
if (!msg.includes('y/N')) {
msg += '(y/N): '
}
}
}

const rl = readline.createInterface({
input: std.stdin,
output: std.stdout,
Expand Down

0 comments on commit 715eec1

Please sign in to comment.