Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions scripts/release/__tests__/write-changelog.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,45 @@ describe('Write changelog', () => {
`);
});

it('should escape double quotes for json files', async () => {
getChangesMock.mockResolvedValue({
changes: [],
changelogText: `## 7.0.1

- React: Make it reactive
- Revert "CLI: Not UI"
- CLI: Not UI`,
});

await writeChangelog(['7.0.1'], {});

expect(fsExtra.writeFile).toHaveBeenCalledTimes(1);
expect(fsExtra.writeFile.mock.calls[0][0]).toBe(STABLE_CHANGELOG_PATH);
expect(fsExtra.writeFile.mock.calls[0][1]).toMatchInlineSnapshot(`
"## 7.0.1

- React: Make it reactive
- Revert "CLI: Not UI"
- CLI: Not UI

## 7.0.0

- Core: Some change"
`);
expect(fsExtra.writeJson).toBeCalledTimes(1);
expect(fsExtra.writeJson.mock.calls[0][0]).toBe(LATEST_VERSION_PATH);
expect(fsExtra.writeJson.mock.calls[0][1]).toMatchInlineSnapshot(`
{
"info": {
"plain": "- React: Make it reactive
- Revert \\"CLI: Not UI\\"
- CLI: Not UI",
},
"version": "7.0.1",
}
`);
});

it('should write to prerelase changelogs and version files in docs', async () => {
getChangesMock.mockResolvedValue({
changes: [],
Expand Down
2 changes: 1 addition & 1 deletion scripts/release/write-changelog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ const writeToDocsVersionFile = async ({
console.log(`📝 Writing changelog to ${chalk.blue(path)}`);
}

const textWithoutHeading = changelogText.split('\n').slice(2).join('\n');
const textWithoutHeading = changelogText.split('\n').slice(2).join('\n').replaceAll('"', '\\"');

const content = {
version,
Expand Down
Loading