Skip to content

Commit

Permalink
Ensure there is always an empty line between the existing content and…
Browse files Browse the repository at this point in the history
… the new content in CHANGELOG.md
  • Loading branch information
lo1tuma committed Sep 25, 2023
1 parent b2440de commit 63a4630
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions source/lib/cli.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ test('does not throw if the repository is dirty', async (t) => {
await cli.run('1.0.0', { sloppy: true, changelogPath: '/foo/CHANGELOG.md' });

t.is(prependFile.callCount, 1);
t.deepEqual(prependFile.firstCall.args, ['/foo/CHANGELOG.md', 'sloppy changelog']);
t.deepEqual(prependFile.firstCall.args, ['/foo/CHANGELOG.md', 'sloppy changelog\n\n']);
});

test('uses custom labels if they are provided in package.json', async (t) => {
Expand Down Expand Up @@ -137,11 +137,11 @@ test('reports the generated changelog', async (t) => {
t.is(createChangelog.firstCall.args[0], '1.0.0');

t.is(prependFile.callCount, 1);
t.deepEqual(prependFile.firstCall.args, ['/foo/CHANGELOG.md', 'generated changelog']);
t.deepEqual(prependFile.firstCall.args, ['/foo/CHANGELOG.md', 'generated changelog\n\n']);
});

test('strips trailing empty lines from the generated changelog', async (t) => {
const createChangelog = stub().returns('generated\nchangelog\nwith\n\na\nlot\n\nof\nempty\nlines\n\n');
const createChangelog = stub().returns('generated\nchangelog\nwith\n\na\nlot\n\nof\nempty\nlines\n\n\n\n\n');
const prependFile = stub().resolves();

const cli = createCli({ createChangelog, prependFile: prependFile as unknown as typeof _prependFile });
Expand All @@ -150,6 +150,6 @@ test('strips trailing empty lines from the generated changelog', async (t) => {

t.deepEqual(prependFile.firstCall.args, [
'/foo/CHANGELOG.md',
'generated\nchangelog\nwith\n\na\nlot\n\nof\nempty\nlines\n'
'generated\nchangelog\nwith\n\na\nlot\n\nof\nempty\nlines\n\n'
]);
});
2 changes: 1 addition & 1 deletion source/lib/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ export function createCliRunner(dependencies: CliRunnerDependencies): CliRunner
validateVersionNumber(newVersionNumber);

const changelog = await generateChangelog(options, githubRepo, validLabels, newVersionNumber);
await prependFile(options.changelogPath, changelog);
await prependFile(options.changelogPath, `${changelog.trim()}\n\n`);
}
};
}

0 comments on commit 63a4630

Please sign in to comment.