Skip to content

Commit

Permalink
fix: remove double escaping for backticks (#68)
Browse files Browse the repository at this point in the history
ISSUES CLOSED: #67
  • Loading branch information
RomanMinkin authored and leonardoanalista committed Mar 14, 2019
1 parent a73e0d9 commit 7aef66f
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 9 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ Here are the options you can set in your `.cz-config.js`:

* scopes: {Array of Strings}: Specify the scopes for your particular project. Eg.: for some banking system: ["acccounts", "payments"]. For another travelling application: ["bookings", "search", "profile"]
* scopeOverrides: {Object where key contains a Array of String}: Use this when you want to override scopes for a specific commit type. Example bellow specify scopes when type is `fix`:
```
```
scopeOverrides: {
fix: [
{name: 'merge'},
Expand Down Expand Up @@ -81,7 +81,7 @@ Here are the options you can set in your `.cz-config.js`:
## GOTCHAS

* backticks
If you wish to have backticks in your content, for example "feat: \`string\`", the commit preview will be "feat: \\\\`string\\\\`".
If you wish to have backticks in your content, for example "feat: \`string\`", the commit preview will be "feat: \\\`string\\\`".
Don't worry because on your `git log` will be "feat: \`string\`" as desired.

* multiline contents on the body of the message
Expand Down
5 changes: 2 additions & 3 deletions buildCommit.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,9 @@ module.exports = function buildCommit(answers, config) {
var specialChars = ['\`'];

specialChars.map(function (item) {
// For some strange reason, we have to pass additional '\' slash to commitizen. Total slashes are 4.
// If user types "feat: `string`", the commit preview should show "feat: `\\string\\`".
// If user types "feat: `string`", the commit preview should show "feat: `\string\`".
// Don't worry. The git log will be "feat: `string`"
result = result.replace(new RegExp(item, 'g'), '\\\\`');
result = result.replace(new RegExp(item, 'g'), '\\`');
});
return result;
}
Expand Down
8 changes: 4 additions & 4 deletions spec/czCustomizableSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ describe('cz-customizable', function() {
var mockCz = getMockedCz(answers);
module.prompter(mockCz, commit);

expect(commit).toHaveBeenCalledWith('feat: with backticks \\\\`here\\\\`');
expect(commit).toHaveBeenCalledWith('feat: with backticks \\`here\\`');
});

it('should not call commit() function if there is no final confirmation and display log message saying commit has been canceled', function() {
Expand Down Expand Up @@ -201,7 +201,7 @@ describe('cz-customizable', function() {
breaking: 'breaking',
footer: 'my footer'
};

module.__set__({
// it mocks winston logging tool
log: {
Expand Down Expand Up @@ -237,7 +237,7 @@ describe('cz-customizable', function() {
breaking: 'breaking',
footer: 'my footer'
};

module.__set__({
// it mocks winston logging tool
log: {
Expand All @@ -260,7 +260,7 @@ describe('cz-customizable', function() {

var mockCz = getMockedCz(answers);
module.prompter(mockCz, commit);

expect(commit).toHaveBeenCalledWith('feat(myScope): create a new cool feature\n\nBREAKING CHANGE:\nbreaking\n\nFIXES: my footer');
});

Expand Down

0 comments on commit 7aef66f

Please sign in to comment.