Skip to content

Commit

Permalink
feat(promopt): ✨ Use autocomplete to improve select experience
Browse files Browse the repository at this point in the history
  • Loading branch information
vivaxy committed Jun 14, 2019
1 parent 5c34f0f commit b3af533
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions lib/prompt.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,15 @@ module.exports = async (emoji) => {
}
}

function suggest(input, choices) {
return choices.filter(function({ title, value }) {
return (
title.toLowerCase().indexOf(input.toLowerCase()) > -1 ||
value.toLowerCase().indexOf(input.toLowerCase()) > -1
);
});
}

// ${type}(${scope}): ${emoji}${subject} \n\n ${body} \n\n ${footer}
const questions = [
{
Expand All @@ -34,6 +43,7 @@ module.exports = async (emoji) => {
message: "Select the type of change that you're committing:",
choices: typeList,
initial: findInitial(typeList, history.type),
suggest,
},
{
type: 'text',
Expand All @@ -47,6 +57,7 @@ module.exports = async (emoji) => {
message: 'Choose a gitmoji:',
choices: gitmojiList,
initial: findInitial(gitmojiList, history.gitmoji),
suggest,
},
{
type: 'text',
Expand Down

0 comments on commit b3af533

Please sign in to comment.