Skip to content

Commit c44f0c3

Browse files
committed
🔨 Refactor: add the ruleWarningMessages
1 parent cda32d1 commit c44f0c3

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

lib/promptConfig.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import chalk from 'chalk';
2-
import { checkRulesMaxLength, checkRulesEndWithDot, checkRulesMinLength } from './rulesConfig';
2+
import ruleWarningMessages from './rules/ruleWarningMessages';
33

44
const choices = (configuration) => {
55
const choicesList = [];
@@ -18,7 +18,7 @@ const choices = (configuration) => {
1818
return choicesList;
1919
};
2020

21-
const questions = (choicesList, configuration) => {
21+
const questions = (choicesList) => {
2222
const questionsList = [
2323
{
2424
type: 'list',
@@ -31,9 +31,10 @@ const questions = (choicesList, configuration) => {
3131
name: 'description',
3232
message: 'Enter your commit message:',
3333
validate: (input) => {
34-
if (checkRulesEndWithDot(input) === false) return 'The commit message can not end with a dot';
35-
else if (checkRulesMaxLength(input) === false) return `The commit message is not allowed to be longer as ${configuration.rules['max-char']}. Consider writing a body.`;
36-
else if (checkRulesMinLength(input) === false) return `The commit message hast to be at least ${configuration.rules['min-char']} character.`;
34+
const warnings = ruleWarningMessages(input);
35+
36+
if (warnings) return warnings;
37+
3738
return true;
3839
},
3940
},

0 commit comments

Comments
 (0)