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(semver): Allow for passing includeBuild into format method #3117

Closed
wants to merge 1 commit into from
Closed

feat(semver): Allow for passing includeBuild into format method #3117

wants to merge 1 commit into from

Conversation

kamilogorek
Copy link
Contributor

ref: #3110

@@ -542,11 +542,14 @@ export class SemVer {
this.format();
}

format(): string {
format({ includeBuild } = { includeBuild: false }): string {
Copy link
Member

Choose a reason for hiding this comment

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

Should this be optional? How about showing the build metadata always?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We cannot do that, as format() call is used for semver comparison, ref: #3110 (comment)

Also:

Although format itself is not pure function, so maybe an alternative just for printing would be preferable.

@justinmchase
Copy link
Contributor

justinmchase commented Jan 17, 2023

It may be wise to just adjust the .toString() function to return the version with metadata and leave the format function alone, for backwards compatibility reasons.

Also, it would be nice if there was a function which returned a new SemVer with the build set. since there is now way to apply build metadata to a version without doing string manipulation at the moment.

var v0 = semver.parse('1.2.3')
var v1 = v0.metadata('4')
console.log(v0.toString()) // 1.2.3
console.log(v1.toString()) // 1.2.3+4

@justinmchase
Copy link
Contributor

I made a more complete version of this PR with some feedback from the discussion:

#3126

@kamilogorek
Copy link
Contributor Author

Closed in favor of #3126

@kamilogorek kamilogorek deleted the semver-include-build branch January 20, 2023 16:11
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.

None yet

3 participants