Skip to content

feat: Add support for prerelease tags (i.e. beta, alpha, etc) while maintaining explicit tag support & default of ‘latest’#22

Open
ghost wants to merge 1 commit intobeshanoe:masterfrom
stevekanter:master
Open

feat: Add support for prerelease tags (i.e. beta, alpha, etc) while maintaining explicit tag support & default of ‘latest’#22
ghost wants to merge 1 commit intobeshanoe:masterfrom
stevekanter:master

Conversation

@ghost
Copy link
Copy Markdown

@ghost ghost commented Jun 13, 2023

I often have beta or alpha packages installed in my projects and using update-by-scope til now has wiped those out. This will allow any prerelease tag that already existed in my package.json to be respected while maintaining full backwards compatibility and support for existing explicit tag overrides.

…aintaining explicit tag support & default of ‘latest’
@beshanoe
Copy link
Copy Markdown
Owner

hey @stevekanter for some reason I missed the notification for your PR :( Great job! I'll take a look soon


if (!tag) {
// Get the minimum version for the package using semver (e.g. ^1.0.0 -> 1.0.0)
const minVersionForPackageSemver = semver.minVersion(version);
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

let's wrap it in trycatch cause some packages might not use semver and this call throws in such cases

const minVersionForPackageSemver = semver.minVersion(version);

// If a prerelease tag was found, use it as the tag
if (minVersionForPackageSemver && typeof minVersionForPackageSemver.prerelease[0] === 'string') {
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

I think it can be simplified using ?.

typeof minVersionForPackageSemver?.prerelease?.[0] === 'string'  

@beshanoe
Copy link
Copy Markdown
Owner

Good job @stevekanter ! Left some comments. One think to note is that the word found in the version doesn't necessarily corresponds to tag, but it most cases it does. But I guess it's pretty safe to assume so

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.

2 participants