Skip to content

Add an option to pass includePrerelease to semver #105

@GGG-KILLER

Description

@GGG-KILLER

Description

I'd like to suggest an option to be able to pass includePrerelease: true (to disable the default behavior in semver) on the semver.satisfies calls (and any other semver call) done in installer.ts:

releasesInfo = releasesInfo.filter((releaseInfo: any) => {
return (
semver.satisfies(
releaseInfo['sdk']['version'],
versionInfo.version()
) ||
semver.satisfies(
releaseInfo['sdk']['version-display'],
versionInfo.version()
)
);
});

Details

This would enable anyone to get the latest preview version of, for example, .NET 5.0 with the 5, 5.0, 5.*, 5.x, 5.0.* or 5.0.x patterns (tested locally with semver 7.3.2 and node.js v14.2.0):

> semver.satisfies("5.0.0-preview.6", "5.0.*")
false
> semver.satisfies("5.0.0-preview.6", "5.0.*", {includePrerelease: true})
true

The default behavior in semver makes it so that prerelease tags aren't matched by semver.satisfies unless you pass the same exact version (making wildcards useless for prerelease matching purposes).
The default behavior would be the current one (includePrerelease: false) to avoid breaking changes.

I would be willing to work on a PR however I created this issue to obtain feedback before I put in any work into it.

Metadata

Metadata

Assignees

Labels

feature requestNew feature or request to improve the current logic

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions