Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix changelog generation on windows #241

Merged
merged 2 commits into from
Oct 7, 2022
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
33 changes: 23 additions & 10 deletions __tests__/plugin-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class TestPlugin extends Plugin {
// always assume v1.0.0 unless specifically overridden
'git describe --tags --abbrev=0': 'v1.0.0',

[`${LERNA_PATH} --next-version=Unreleased --from=v1.0.0`]:
[`${process.execPath} ${LERNA_PATH} --next-version=Unreleased --from=v1.0.0`]:
'## Unreleased (2020-03-18)\n\nThe changelog',
};

Expand Down Expand Up @@ -95,7 +95,10 @@ describe('@release-it-plugins/lerna-changelog', () => {

expect(plugin.commands).toStrictEqual([
['git describe --tags --abbrev=0', { write: false }],
[`${LERNA_PATH} --next-version=Unreleased --from=v1.0.0`, { write: false }],
[
`${process.execPath} ${LERNA_PATH} --next-version=Unreleased --from=v1.0.0`,
{ write: false },
],
]);
});

Expand All @@ -109,7 +112,10 @@ describe('@release-it-plugins/lerna-changelog', () => {

expect(plugin.commands).toStrictEqual([
['git describe --tags --abbrev=0', { write: false }],
[`${LERNA_PATH} --next-version=Unreleased --from=v1.0.0`, { write: false }],
[
`${process.execPath} ${LERNA_PATH} --next-version=Unreleased --from=v1.0.0`,
{ write: false },
],
]);

const changelog = fs.readFileSync(infile, { encoding: 'utf8' });
Expand All @@ -130,7 +136,8 @@ describe('@release-it-plugins/lerna-changelog', () => {
let infile = tmp.fileSync().name;
let plugin = buildPlugin({ infile });

plugin.responses[`${LERNA_PATH} --next-version=Unreleased --from=v1.0.0`] = '';
plugin.responses[`${process.execPath} ${LERNA_PATH} --next-version=Unreleased --from=v1.0.0`] =
'';

await runTasks(plugin);

Expand All @@ -150,15 +157,15 @@ describe('@release-it-plugins/lerna-changelog', () => {
value: 'hahahahaah, does not exist',
},
'git rev-list --max-parents=0 HEAD': 'aabc',
[`${LERNA_PATH} --next-version=Unreleased --from=aabc`]: `## Unreleased\n\nThe changelog\n## v1.0.0\n\nThe old changelog`,
[`${process.execPath} ${LERNA_PATH} --next-version=Unreleased --from=aabc`]: `## Unreleased\n\nThe changelog\n## v1.0.0\n\nThe old changelog`,
});

await runTasks(plugin);

expect(plugin.commands).toStrictEqual([
['git describe --tags --abbrev=0', { write: false }],
['git rev-list --max-parents=0 HEAD', { write: false }],
[`${LERNA_PATH} --next-version=Unreleased --from=aabc`, { write: false }],
[`${process.execPath} ${LERNA_PATH} --next-version=Unreleased --from=aabc`, { write: false }],
]);

const changelog = fs.readFileSync(infile, { encoding: 'utf8' });
Expand All @@ -174,16 +181,19 @@ describe('@release-it-plugins/lerna-changelog', () => {

Object.assign(plugin.responses, {
'git rev-list --max-parents=0 HEAD': 'aabc',
[`${LERNA_PATH} --next-version=Unreleased --from=aabc`]: `## Unreleased\n\nThe changelog\n## v1.0.0\n\nThe old changelog`,
[`${process.execPath} ${LERNA_PATH} --next-version=Unreleased --from=aabc`]: `## Unreleased\n\nThe changelog\n## v1.0.0\n\nThe old changelog`,
});

await runTasks(plugin);

expect(plugin.commands).toStrictEqual([
['git describe --tags --abbrev=0', { write: false }],
[`${LERNA_PATH} --next-version=Unreleased --from=v1.0.0`, { write: false }],
[
`${process.execPath} ${LERNA_PATH} --next-version=Unreleased --from=v1.0.0`,
{ write: false },
],
['git rev-list --max-parents=0 HEAD', { write: false }],
[`${LERNA_PATH} --next-version=Unreleased --from=aabc`, { write: false }],
[`${process.execPath} ${LERNA_PATH} --next-version=Unreleased --from=aabc`, { write: false }],
[`git add ${infile}`, {}],
]);

Expand Down Expand Up @@ -296,7 +306,10 @@ describe('@release-it-plugins/lerna-changelog', () => {
} catch (error) {
expect(plugin.commands).toStrictEqual([
['git describe --tags --abbrev=0', { write: false }],
[`${LERNA_PATH} --next-version=Unreleased --from=v1.0.0`, { write: false }],
[
`${process.execPath} ${LERNA_PATH} --next-version=Unreleased --from=v1.0.0`,
{ write: false },
],
]);

expect(error.message).toEqual(
Expand Down
9 changes: 6 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,12 @@ export default class LernaChangelogGeneratorPlugin extends Plugin {
}

async _execLernaChangelog(from) {
let changelog = await this.exec(`${LERNA_PATH} --next-version=${UNRELEASED} --from=${from}`, {
options: { write: false },
});
let changelog = await this.exec(
`${process.execPath} ${LERNA_PATH} --next-version=${UNRELEASED} --from=${from}`,
{
options: { write: false },
}
);

return changelog;
}
Expand Down