mirror of
https://github.com/serverless/serverless.git
synced 2026-01-25 15:07:39 +00:00
Merge pull request #572 from pmuens/add-cancel-interactive-prompt-functionality
Closes #528 - Add cancel interactive prompt functionality
This commit is contained in:
commit
8b6faf97e4
@ -332,8 +332,11 @@ exports.select = function(message, choices, multi, doneLabel) {
|
||||
selectStateDown(4);
|
||||
} else if (key.name == 'return' || key.name == 'space' || key.name == 'enter') {
|
||||
|
||||
// Check if "done" option or ctrl was pressed.
|
||||
if ((Select.state.choices[Select.state.index - 1].action
|
||||
// Check if "cancel" option, "done" option or ctrl was pressed.
|
||||
if (Select.state.choices[Select.state.index - 1].action
|
||||
&& Select.state.choices[Select.state.index - 1].action.toLowerCase() === 'cancel') {
|
||||
process.exit();
|
||||
} else if ((Select.state.choices[Select.state.index - 1].action
|
||||
&& Select.state.choices[Select.state.index - 1].action.toLowerCase() === 'done') || key.name == 'enter') {
|
||||
process.stdin.removeListener('keypress', keypressHandler);
|
||||
return Select._close();
|
||||
@ -380,7 +383,12 @@ exports.select = function(message, choices, multi, doneLabel) {
|
||||
{
|
||||
action: 'Done',
|
||||
label: Select.state.doneLabel,
|
||||
});
|
||||
},
|
||||
{
|
||||
action: 'Cancel',
|
||||
label: 'Cancel'
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
// Log Message
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user