Skip to content

Commit 99d8881

Browse files
cherryblossom000AdeAttwood
authored andcommitted
fix(cz-commitlint): fix minor formatting issues
This commit adds a space after the title before the skip message and removes the double colon in the `config-conventional` type of change prompt. For example (when using `@commitlint/config-conventional`), the following would previously be printed: ``` Select the type of change that you're committing:: feat What is the scope of this change (e.g. component or file name)(press enter to skip): (max 96 chars) ``` Now with this change: ``` Select the type of change that you're committing: feat What is the scope of this change (e.g. component or file name) (press enter to skip): (max 96 chars) ```
1 parent 15d3b9d commit 99d8881

File tree

3 files changed

+15
-9
lines changed

3 files changed

+15
-9
lines changed

Diff for: @commitlint/config-conventional/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ module.exports = {
3636
prompt: {
3737
questions: {
3838
type: {
39-
description: "Select the type of change that you're committing:",
39+
description: "Select the type of change that you're committing",
4040
enum: {
4141
feat: {
4242
description: 'A new feature',

Diff for: @commitlint/cz-commitlint/src/Question.test.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ describe('message', () => {
102102
enumList: ['cli', 'core'],
103103
}).question;
104104
expect(question).toHaveProperty('message', expect.any(Function));
105-
expect((question.message as any)()).toBe('please input: ');
105+
expect((question.message as any)()).toBe('please input:');
106106
});
107107

108108
test('should display skip hint when it is input and can skip', () => {
@@ -112,7 +112,7 @@ describe('message', () => {
112112
}).question;
113113
expect(question).toHaveProperty('message', expect.any(Function));
114114
expect((question.message as any)()).toBe(
115-
'please input(press enter to skip): \n'
115+
'please input (press enter to skip):\n'
116116
);
117117
});
118118

@@ -123,7 +123,7 @@ describe('message', () => {
123123
skip: true,
124124
} as any).question;
125125
expect(question).toHaveProperty('message', expect.any(Function));
126-
expect((question.message as any)()).toBe('please input: \n');
126+
expect((question.message as any)()).toBe('please input:\n');
127127
});
128128

129129
test('should display upper limit hint when it is input and has max length', () => {
@@ -155,7 +155,7 @@ describe('message', () => {
155155
} as any).question;
156156
expect(question).toHaveProperty('message', expect.any(Function));
157157
expect((question.message as any)()).toBe(
158-
'please input(press enter to skip): 10 chars at least, upper 80 chars\n'
158+
'please input (press enter to skip): 10 chars at least, upper 80 chars\n'
159159
);
160160
});
161161

Diff for: @commitlint/cz-commitlint/src/Question.ts

+10-4
Original file line numberDiff line numberDiff line change
@@ -176,11 +176,17 @@ export default class Question {
176176
return messages.join(', ');
177177
})();
178178

179-
const skipMessage = this.skip ? this.getMessage('skip') : '';
180-
181-
return this.title + skipMessage + ': ' + countLimitMessage + '\n';
179+
const skipMessage = this.skip && this.getMessage('skip');
180+
181+
return (
182+
this.title +
183+
(skipMessage ? ` ${skipMessage}` : '') +
184+
':' +
185+
(countLimitMessage ? ` ${countLimitMessage}` : '') +
186+
'\n'
187+
);
182188
} else {
183-
return this.title + ': ';
189+
return `${this.title}:`;
184190
}
185191
}
186192
}

0 commit comments

Comments
 (0)