Skip to content

Commit

Permalink
Remove confirmation values filter
Browse files Browse the repository at this point in the history
Use 'y' and 'N' instead of filtering them to booleans as the filtered
value is printed to the console and is confusing is differs from the one
user typed.
  • Loading branch information
lyyder committed Nov 26, 2018
1 parent fb00bab commit aaa2567
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions translations.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,10 +137,10 @@ const run = () => {
return confirmTranslation(targetLang, key, translation);
})
.then(answers => {
// a bool value if translation addition is confirmed
// 'y' or 'N'
const confirmation = answers.value;

if (!confirmation) {
if (confirmation === 'N') {
console.log('Discarding new translation');
throw new BreakSignal();
}
Expand Down Expand Up @@ -237,7 +237,7 @@ const addTranslation = (targetLang, key, source) => {
* @param {String} key Key for the new translation
* @param {Object} source Source language translations
*
* @return a Promise with the answers hash containing a boolean value field
* @return a Promise with with answers.value being 'y' or 'N'
*/
const confirmTranslation = (targetLang, key, translation) => {
return inquirer.prompt([
Expand All @@ -247,8 +247,7 @@ const confirmTranslation = (targetLang, key, translation) => {
message: `Do you want to add the ${targetLangName(targetLang)} translation ${chalk.green(
translation
)} for the key ${chalk.blueBright(key)}? (y/N)`,
filter: value => (value === 'y' ? true : value === 'N' ? false : value),
validate: value => value === true || value === false,
validate: value => value === 'y' || value === 'N',
},
]);
};
Expand Down

0 comments on commit aaa2567

Please sign in to comment.