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

tests: fix parseReleases #265

Merged
merged 3 commits into from
Sep 11, 2024
Merged

tests: fix parseReleases #265

merged 3 commits into from
Sep 11, 2024

Conversation

Reddine
Copy link
Contributor

@Reddine Reddine commented May 19, 2023

Closes #264

src/releases.js Outdated
@@ -10,7 +10,7 @@ const parseReleases = async (tags, options, onParsed) => {
const merges = commits.filter(commit => commit.merge).map(commit => commit.merge)
const fixes = commits.filter(commit => commit.fixes).map(commit => ({ fixes: commit.fixes, commit }))

for (const plugin of options.plugins) {
for (const plugin of Array.from(options.plugins || [])) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why Array.from? what will it be if it's truthy but not an array?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggested Array.from because it's the shortest way to check if plugins is iterable. any other suggestion?

In that case the test might pass due to the conditions inside the loop.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[].concat(options.plugins || []) will be much faster, but also it's fine if options.plugins throws here when passed a truthy non-iterable value.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I applied your suggestion, thanks!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(by the "fine" part i mean it would be fine to have options.plugins || [] by itself. if it ends up non-iterable, it should throw)

@Reddine Reddine changed the title tests: make sure options.plugins is iterable tests: fix parseReleases May 20, 2023
@Reddine Reddine requested a review from ljharb May 23, 2023 12:27
@ljharb
Copy link
Contributor

ljharb commented May 23, 2023

Now all it needs is tests :-)

@cookpete cookpete merged commit 03811f7 into cookpete:master Sep 11, 2024
@ljharb
Copy link
Contributor

ljharb commented Sep 11, 2024

@cookpete note that this has no tests yet

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Test of releases are failing
3 participants