-
-
Notifications
You must be signed in to change notification settings - Fork 33.7k
process: add lots of version properties #19438
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
Conversation
|
-1 because such checks (as suggested in the docs) reduce readability and it ignores release status. |
|
I'd rather prefer separate properties for each part of the version and a flag for release mode (if there isn't already one that I'm overlooking). This way versions checks are still just as easy/foolproof but are more understandable. |
|
@mscdex this is definitely not intended for readability. i have checks like: const meetsVersion = (() => {
if (process.versionMajor > 9)
return true;
return process.versionMajor === 9 && process.versionMinor === 8;
})();and i might need that in three or four places for my tests, coverage, release scripts, etc and that doesn't fit very well into a |
8aa5bb9 to
3db4f8c
Compare
doc/api/process.md
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd prefer dropping this off process.release also to avoid adding anything new to the process object.
doc/api/process.md
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
'semver tagis not very descriptive. Perhaps aprerelease` property with a simple bool would work here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe prereleaseTag? i want to expose the actual tag itself, not just if node is pre-release
doc/api/process.md
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will the fact that the computed version does not incorporate the pre-release tag impact anything here? For instance, every version built on master will have the same computed version until the next major release.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is process.computedVersion >= 591872 && process.prerelaseTag good enough?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, as long as folks know to check both. Perhaps an additional note in the docs?
|
#19438 (comment) hidden but maybe still unresolved |
fd74a60 to
24ec761
Compare
doc/api/process.md
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this entire description is unnecessary as it should be pretty obvious how the version properties could be used. At the very least, 'this' should be more specific as there are multiple properties shown above.
4badf01 to
6e03bd6
Compare
|
A couple questions:
|
if (process.release.computedVersion < 591616) {
throw new Error('vm.Module not available before node 9.7')
}
// vs
if (process.release.majorVersion < 9 || (process.release.majorVersion === 9 && process.release.minorVersion < 7)) {
throw new Error('vm.Module not available before node 9.7')
}node -e "process.release.computedVersion > 591872 || process.exit(1)"
if [ $? ]; then
npm run coverage
fi
# vs
node -e "process.release.majorVersion > 9 || (process.release.majorVersion == 9 && process.release.minorVersion > 8) || process.exit(1)"
if [ $? ]; then
npm run coverage
fietc...
i have no idea, i don't use python, php, etc. however, this provides a similar mechanism to people building node addons using NODE_MODULE_VERSION and friends to support lots and lots of node versions |
|
The computed version isn't super readable. I use SemVer.satisfies(process.version, ">=8.5.0")For the |
like i said before, it isn't designed for readability, and its absolutely bonkers that i would need to install an entire module just to perform a version check. if that's the path we're gonna take we should ship semver with node, and if shipping semver with node seems silly then there's your answer.
what do you mean by that? if you mean when do the values overflow, we can't go higher than 255 for patch/minor and ~4398046511103 (with js's numbers) for the major |
Maybe make the the
I meant is there any combo of major + min + patch that could cause 2 computed values to be the same.
Overflow is another concern. |
> 1 << 16 // major version 1
65536
> 256 << 8 // minor version 256
65536
// ^^ will never happen, we're not going to release anywhere near 250 patch or minors
i'm ok with something like |
|
I think avoiding hard-to-reason-about numbers in source is a good thing. Hiding away the computed version behind a reasonable API also means the formula for computing it can change/adjust as needed. |
|
I like the idea of |
6e03bd6 to
74aac56
Compare
|
i've added compareVersion, the only thing that worries me is that it involves calling a function which might not exist, but its a fairly easy check |
PR-URL: #19438 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Gireesh Punathil <[email protected]>
|
@mscdex If you still feel strongly that this should not be in core, options are:
If @mscdex objects, option for anyone who feels strongly that this should remain on master and go into releases would be to add the |
|
How can this be landed with linting error? This line exceeds length limit. |
|
Last CI had a wrong PR number) |
One more data point for "more automation, less manual entry"... |
Introduced in #19438 PR-URL: #19542 Reviewed-By: Rich Trott <[email protected]> Reviewed-By: Richard Lau <[email protected]>
Wasn't the intention behind adding |
Since this hasn't gone out in a release yet, it's not too late to remove stuff if there's agreement on it. |
|
I agree this should not have landed yet. A revert would be appropriate |
This reverts commit 982e3bd. It is believed that the original PR should not have landed as it is as the implemented and exposed API has a variety of flaws. PR-URL: #19577 Refs: #19438 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Michaël Zasso <[email protected]> Reviewed-By: Gus Caplan <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Richard Lau <[email protected]>
Checklist
make -j4 test(UNIX), orvcbuild test(Windows) passes