Skip to content

Commit 5504430

Browse files
committed
fix(engine): removed maxBodyLineWidth property
1 parent f828405 commit 5504430

File tree

2 files changed

+36
-42
lines changed

2 files changed

+36
-42
lines changed

engine.js

+36-41
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,23 @@ var map = require('lodash.map');
55
var longest = require('longest');
66
var chalk = require('chalk');
77

8-
var filter = function(array) {
9-
return array.filter(function(x) {
8+
var filter = function (array) {
9+
return array.filter(function (x) {
1010
return x;
1111
});
1212
};
1313

14-
var headerLength = function(answers) {
14+
var headerLength = function (answers) {
1515
return (
1616
answers.type.length + 2 + (answers.scope ? answers.scope.length + 2 : 0)
1717
);
1818
};
1919

20-
var maxSummaryLength = function(options, answers) {
20+
var maxSummaryLength = function (options, answers) {
2121
return options.maxHeaderWidth - headerLength(answers);
2222
};
2323

24-
var filterSubject = function(subject) {
24+
var filterSubject = function (subject) {
2525
subject = subject.trim();
2626
if (subject.charAt(0).toLowerCase() !== subject.charAt(0)) {
2727
subject =
@@ -36,14 +36,14 @@ var filterSubject = function(subject) {
3636
// This can be any kind of SystemJS compatible module.
3737
// We use Commonjs here, but ES6 or AMD would do just
3838
// fine.
39-
module.exports = function(options) {
39+
module.exports = function (options) {
4040
var types = options.types;
4141

4242
var length = longest(Object.keys(types)).length + 1;
43-
var choices = map(types, function(type, key) {
43+
var choices = map(types, function (type, key) {
4444
return {
4545
name: (key + ':').padEnd(length) + ' ' + type.description,
46-
value: key
46+
value: key,
4747
};
4848
});
4949

@@ -59,7 +59,7 @@ module.exports = function(options) {
5959
//
6060
// By default, we'll de-indent your commit
6161
// template and will keep empty lines.
62-
prompter: function(cz, commit) {
62+
prompter: function (cz, commit) {
6363
// Let's ask some questions of the user
6464
// so that we can populate our commit
6565
// template.
@@ -73,32 +73,32 @@ module.exports = function(options) {
7373
name: 'type',
7474
message: "Select the type of change that you're committing:",
7575
choices: choices,
76-
default: options.defaultType
76+
default: options.defaultType,
7777
},
7878
{
7979
type: 'input',
8080
name: 'scope',
8181
message:
8282
'What is the scope of this change (e.g. component or file name): (press enter to skip)',
8383
default: options.defaultScope,
84-
filter: function(value) {
84+
filter: function (value) {
8585
return options.disableScopeLowerCase
8686
? value.trim()
8787
: value.trim().toLowerCase();
88-
}
88+
},
8989
},
9090
{
9191
type: 'input',
9292
name: 'subject',
93-
message: function(answers) {
93+
message: function (answers) {
9494
return (
9595
'Write a short, imperative tense description of the change (max ' +
9696
maxSummaryLength(options, answers) +
9797
' chars):\n'
9898
);
9999
},
100100
default: options.defaultSubject,
101-
validate: function(subject, answers) {
101+
validate: function (subject, answers) {
102102
var filteredSubject = filterSubject(subject);
103103
return filteredSubject.length == 0
104104
? 'subject is required'
@@ -110,99 +110,94 @@ module.exports = function(options) {
110110
filteredSubject.length +
111111
' characters.';
112112
},
113-
transformer: function(subject, answers) {
113+
transformer: function (subject, answers) {
114114
var filteredSubject = filterSubject(subject);
115115
var color =
116116
filteredSubject.length <= maxSummaryLength(options, answers)
117117
? chalk.green
118118
: chalk.red;
119119
return color('(' + filteredSubject.length + ') ' + subject);
120120
},
121-
filter: function(subject) {
121+
filter: function (subject) {
122122
return filterSubject(subject);
123-
}
123+
},
124124
},
125125
{
126126
type: 'input',
127127
name: 'body',
128-
message: function(answers) {
129-
return (
130-
'Provide a longer description of the change (max ' +
131-
options.maxBodyLineWidth +
132-
' chars per line): (press enter to skip)\n'
133-
);
134-
},
128+
message:
129+
'Provide a longer description of the change: (press enter to skip)\n',
135130
default: options.defaultBody,
136-
transformer: function(body) {
131+
transformer: function (body) {
137132
var color = chalk.green;
138133
return color('(' + body.length + ') ' + body);
139-
}
134+
},
140135
},
141136
{
142137
type: 'confirm',
143138
name: 'isBreaking',
144139
message: 'Are there any breaking changes?',
145-
default: false
140+
default: false,
146141
},
147142
{
148143
type: 'input',
149144
name: 'breakingBody',
150145
default: '-',
151146
message:
152147
'A BREAKING CHANGE commit requires a body. Please enter a longer description of the commit itself:\n',
153-
when: function(answers) {
148+
when: function (answers) {
154149
return answers.isBreaking && !answers.body;
155150
},
156-
validate: function(breakingBody, answers) {
151+
validate: function (breakingBody, answers) {
157152
return (
158153
breakingBody.trim().length > 0 ||
159154
'Body is required for BREAKING CHANGE'
160155
);
161-
}
156+
},
162157
},
163158
{
164159
type: 'input',
165160
name: 'breaking',
166161
message: 'Describe the breaking changes:\n',
167-
when: function(answers) {
162+
when: function (answers) {
168163
return answers.isBreaking;
169-
}
164+
},
170165
},
171166

172167
{
173168
type: 'confirm',
174169
name: 'isIssueAffected',
175170
message: 'Does this change affect any open issues?',
176-
default: options.defaultIssues ? true : false
171+
default: options.defaultIssues ? true : false,
177172
},
178173
{
179174
type: 'input',
180175
name: 'issuesBody',
181176
default: '-',
182177
message:
183178
'If issues are closed, the commit requires a body. Please enter a longer description of the commit itself:\n',
184-
when: function(answers) {
179+
when: function (answers) {
185180
return (
186181
answers.isIssueAffected && !answers.body && !answers.breakingBody
187182
);
188-
}
183+
},
189184
},
190185
{
191186
type: 'input',
192187
name: 'issues',
193188
message: 'Add issue references (e.g. "fix #123", "re #123".):\n',
194-
when: function(answers) {
189+
when: function (answers) {
195190
return answers.isIssueAffected;
196191
},
197-
default: options.defaultIssues ? options.defaultIssues : undefined
198-
}
199-
]).then(function(answers) {
192+
default: options.defaultIssues ? options.defaultIssues : undefined,
193+
},
194+
]).then(function (answers) {
200195
var wrapOptions = {
201196
trim: true,
202197
cut: false,
203198
newline: '\n',
204199
indent: '',
205-
width: options.maxLineWidth
200+
width: options.maxLineWidth,
206201
};
207202

208203
// parentheses are only needed when a scope is present
@@ -225,6 +220,6 @@ module.exports = function(options) {
225220

226221
commit(filter([head, body, breaking, issues]).join('\n\n'));
227222
});
228-
}
223+
},
229224
};
230225
};

index.js

-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ var options = {
2424
parseInt(process.env.CZ_MAX_LINE_WIDTH)) ||
2525
config.maxLineWidth ||
2626
100,
27-
maxBodyLineWidth: config.maxBodyLineWidth || 80
2827
};
2928

3029
(function(options) {

0 commit comments

Comments
 (0)