Skip to content

Commit f862950

Browse files
authored
Merge branch 'master' into ci/node8
2 parents c72e33e + 866cffd commit f862950

File tree

10 files changed

+35
-35
lines changed

10 files changed

+35
-35
lines changed

.sgcrc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"body": true,
44
"emoji": false,
55
"lowercaseTypes": false,
6-
"initial-commit": {
6+
"initialCommit": {
77
"isEnabled": true,
88
"emoji": ":tada:",
99
"message": "Initial commit"
@@ -56,8 +56,8 @@
5656
}
5757
],
5858
"rules": {
59-
"max-char": 72,
60-
"min-char": 10,
61-
"end-with-dot": false
59+
"maxChar": 72,
60+
"minChar": 10,
61+
"endWithDot": false
6262
}
6363
}

lib/cli.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ if (argv.v) {
4646
} else if (!isAdded()) {
4747
console.error(chalk.red('Please', chalk.bold('git add'), 'some files first before you commit.'));
4848
} else if (commitCount() === 0 &&
49-
typeof config['initial-commit'] === 'object' &&
50-
config['initial-commit'].isEnabled) {
49+
typeof config.initCommit === 'object' &&
50+
config.initCommit.isEnabled) {
5151
const message = initMessage(config);
5252

5353
inquirer.prompt(question).then(answers => (

lib/getConfig.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ const getConfig = (altPath) => {
3535
tempConfig.types = config.types;
3636
}
3737

38-
if (config['initial-commit']) {
39-
tempConfig['initial-commit'] = config['initial-commit'];
38+
if (config.initialCommit) {
39+
tempConfig.initialCommit = config.initialCommit;
4040
}
4141

4242
// next will remove "inherit" from the config

lib/questions.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@ const initMessage = (config) => {
2323
let message = '';
2424

2525
if (config.emoji &&
26-
typeof config['initial-commit'] === 'object' &&
27-
config['initial-commit'].isEnabled) {
28-
message = `${config['initial-commit'].emoji} ${config['initial-commit'].message}`;
26+
typeof config.initialCommit === 'object' &&
27+
config.initialCommit.isEnabled) {
28+
message = `${config.initialCommit.emoji} ${config.initialCommit.message}`;
2929
} else {
30-
message = config['initial-commit'].message;
30+
message = config.initialCommit.message;
3131
}
3232

3333
return message;

lib/rules/availableRules.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ const rules = {
1010
},
1111
}),
1212
maxChar: (input, config) => ({
13-
message: () => `The commit message is not allowed to be longer as ${config.rules['max-char']} character, but is ${input.length} character long. Consider writing a body.`,
13+
message: () => `The commit message is not allowed to be longer as ${config.rules.maxChar} character, but is ${input.length} character long. Consider writing a body.`,
1414
check: () => {
15-
let number = config.rules['max-char'];
15+
let number = config.rules.maxChar;
1616

1717
if (number === -1) {
1818
number = Number.POSITIVE_INFINITY;
@@ -26,9 +26,9 @@ const rules = {
2626
},
2727
}),
2828
minChar: (input, config) => ({
29-
message: () => `The commit message has to be at least ${config.rules['min-char']} character, but is only ${input.length} character long.`,
29+
message: () => `The commit message has to be at least ${config.rules.minChar} character, but is only ${input.length} character long.`,
3030
check: () => {
31-
if (input.length < config.rules['min-char']) {
31+
if (input.length < config.rules.minChar) {
3232
return false;
3333
}
3434

lib/rules/ruleWarningMessages.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ const ruleWarningMessages = (input, config) => {
77
const configRuleEntries = entries(config.rules);
88

99
configRuleEntries.forEach((rule) => {
10-
const camelCaseRuleName = (rule[0]).replace(/-([a-z])/g, g => (g[1].toUpperCase()));
11-
const ruleIs = rules[camelCaseRuleName](input, config).check();
10+
const ruleName = rule[0];
11+
const ruleIs = rules[ruleName](input, config).check();
1212

1313
if (!ruleIs) {
14-
warningMessage += `${rules[camelCaseRuleName](input, config).message()}\n`;
14+
warningMessage += `${rules[ruleName](input, config).message()}\n`;
1515
}
1616
});
1717

test/fixtures/.sgcrc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"body": true,
44
"emoji": false,
55
"lowercaseTypes": false,
6-
"initial-commit": {
6+
"initialCommit": {
77
"isEnabled": true,
88
"emoji": ":tada:",
99
"message": "Initial commit"
@@ -16,8 +16,8 @@
1616
}
1717
],
1818
"rules": {
19-
"max-char": 72,
20-
"min-char": 10,
21-
"end-with-dot": false
19+
"maxChar": 72,
20+
"minChar": 10,
21+
"endWithDot": false
2222
}
2323
}

test/questions.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ test('INIT COMMIT | check message without emoji', (t) => {
136136
const config = getConfig();
137137
const message = initMessage(config);
138138

139-
t.is(message, config['initial-commit'].message);
139+
t.is(message, config.initialCommit.message);
140140
});
141141

142142
test('INIT COMMIT | check message with emoji', (t) => {
@@ -146,14 +146,14 @@ test('INIT COMMIT | check message with emoji', (t) => {
146146

147147
const message = initMessage(config);
148148

149-
t.is(message, `${config['initial-commit'].emoji} ${config['initial-commit'].message}`);
149+
t.is(message, `${config.initialCommit.emoji} ${config.initialCommit.message}`);
150150
});
151151

152152
test('INIT QUESTION | check message without emoji', (t) => {
153153
const config = getConfig();
154154
const question = initQuestion(config);
155155

156-
t.is(question.message, `Confirm as first commit message: "${config['initial-commit'].message}"`);
156+
t.is(question.message, `Confirm as first commit message: "${config.initialCommit.message}"`);
157157
});
158158

159159
test('INIT QUESTION | check message with emoji', (t) => {
@@ -163,5 +163,5 @@ test('INIT QUESTION | check message with emoji', (t) => {
163163

164164
const question = initQuestion(config);
165165

166-
t.is(question.message, `Confirm as first commit message: "${config['initial-commit'].emoji} ${config['initial-commit'].message}"`);
166+
t.is(question.message, `Confirm as first commit message: "${config.initialCommit.emoji} ${config.initialCommit.message}"`);
167167
});

test/rules/availableRules.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import rules from '../../lib/rules/availableRules';
44

55
test('rules endWithDot', (t) => {
66
const rulesObj = {
7-
'end-with-dot': false,
7+
endWithDot: false,
88
};
99
const endWithDot = rules.endWithDot('input with dot.', { rules: rulesObj }).check();
1010
const endWithoutDot = rules.endWithDot('input with dot', { rules: rulesObj }).check();
@@ -15,7 +15,7 @@ test('rules endWithDot', (t) => {
1515

1616
test('rules minChar', (t) => {
1717
const rulesObj = {
18-
'min-char': 10,
18+
minChar: 10,
1919
};
2020
const notMinChar = rules.minChar('less', { rules: rulesObj }).check();
2121
const minChar = rules.minChar('this are more than 10 characters', { rules: rulesObj }).check();
@@ -26,7 +26,7 @@ test('rules minChar', (t) => {
2626

2727
test('-1 in minChar', (t) => {
2828
const rulesObj = {
29-
'min-char': -1,
29+
minChar: -1,
3030
};
3131
const shortText = rules.minChar('n', { rules: rulesObj }).check();
3232
const longText = rules.minChar('this are more than 10 characters', { rules: rulesObj }).check();
@@ -37,7 +37,7 @@ test('-1 in minChar', (t) => {
3737

3838
test('rules mxChar', (t) => {
3939
const rulesObj = {
40-
'max-char': 72,
40+
maxChar: 72,
4141
};
4242
const moreThanMaxChar = rules.maxChar('this are more than 72 characters, believe me or not but the value moreThanMaxChar will be false ;-P', { rules: rulesObj }).check();
4343
const lessThanMaxChar = rules.maxChar('this are less than 72 characters', { rules: rulesObj }).check();
@@ -48,7 +48,7 @@ test('rules mxChar', (t) => {
4848

4949
test('-1 in maxChar', (t) => {
5050
const rulesObj = {
51-
'max-char': -1,
51+
maxChar: -1,
5252
};
5353
const longText = rules.maxChar('this are more than 72 characters, believe me or not but the value moreThanMaxChar will be true ;-P', { rules: rulesObj }).check();
5454
const shortText = rules.maxChar('this are less than 72 characters', { rules: rulesObj }).check();

test/rules/ruleWarningMessages.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ import ruleWaringMessages from '../../lib/rules/ruleWarningMessages';
55
test('ruleWarningMessages', (t) => {
66
const config = {
77
rules: {
8-
'max-char': 72,
9-
'min-char': 10,
10-
'end-with-dot': false,
8+
maxChar: 72,
9+
minChar: 10,
10+
endWithDot: false,
1111
},
1212
};
1313
const messages = ruleWaringMessages('input.', config);

0 commit comments

Comments
 (0)