Methods
bell() → {Promise}
Rings an auditory bell when prompting for input.
Returns:
resolves when the sound is finished playing, or immediately if bell is disabled.
- Type
- Promise
(private) formatYesNo(defaultVal) → {Object}
Provides the format for the "Y/N" prompt.
Parameters:
Name | Type | Description |
---|---|---|
defaultVal |
String | the default value for the question. |
Returns:
{ y, n }
containing formatted strings for the Y
and N
parts of the default input.
- Type
- Object
status(msg) → {void}
Provides a section header to mark a section of script running.
Parameters:
Name | Type | Description |
---|---|---|
msg |
String | the message to print. |
Returns:
- Type
- void
yesNo(question, consoleDefault, ciDefault) → {Promise.<Boolean>}
Queries the user for a "yes/no" question. If in CI, uses a default, and creates fake console output to simulate asking the question to the user and getting a response, to allow the user to follow along.
Example
const io = new IO();
io
.yesNo("Use current directory, instead of '/var/my-app/'?", "Y", "N")
.then(answer => console.log(answer ? "Using current directory." : "Using '/var/my-app/'."));
Parameters:
Name | Type | Description |
---|---|---|
question |
String | the text of the question to ask the user. |
consoleDefault |
String | the default input if the user doesn't provide input. Use |
ciDefault |
String | the default input to use in CI. Use |
Returns:
true
if the user answered "yes", false
if the user answered "no".
- Type
- Promise.<Boolean>