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

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ghost
Copy link

@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
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
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
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
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