-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(lambda): replace package prompt with readline
To get around the colors dependency in prompt
- Loading branch information
1 parent
d06751e
commit bf85c6b
Showing
2 changed files
with
11 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,18 @@ | ||
'use strict'; | ||
|
||
var prompt = require('prompt'); | ||
var chalk = require('chalk'); | ||
var readline = require('readline'); | ||
|
||
module.exports = function (message) { | ||
var yesno = { | ||
name: 'yesno', | ||
message: message, | ||
validator: /y[es]*|n[o]?/i, | ||
warning: 'Must respond yes or no', | ||
default: 'no', | ||
}; | ||
return new Promise(function (resolve) { | ||
var rl = readline.createInterface({ | ||
input: process.stdin, | ||
output: process.stdout, | ||
}); | ||
|
||
return new Promise(function (resolve, reject) { | ||
prompt.get(yesno, function (error, answer) { | ||
if (error) { | ||
return reject(error); | ||
} | ||
resolve(answer.yesno[0] === 'y'); | ||
rl.question(`${message} ${chalk.gray('yes/[no]')}`, function (answer) { | ||
rl.close(); | ||
resolve(/^y(es)?$/i.test(answer)); | ||
}); | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters