Repository navigation
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
Changes from 1 commit
67f79a5
81763c4
f64a994
4896ba5
c1e4e01
85cbf8d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1890,6 +1890,20 @@ The `process.version` property returns the Node.js version string. | |
| console.log(`Version: ${process.version}`); | ||
| ``` | ||
|
|
||
| ## process.computedVersion | ||
| <!-- YAML | ||
| added: REPLACEME | ||
| --> | ||
|
|
||
| * {number} | ||
|
|
||
| The `process.computedVersion` property is the result of | ||
| `(NODE_MAJOR_VERSION << 16) + (NODE_MINOR_VERSION << 8) + NODE_PATCH_VERSION` | ||
|
|
||
| This property is useful for inline version checks. Using the process above a | ||
| number such as `591872` (for version `9.8.0`) may be selected and easily used | ||
| for a version check (`process.computedVersion >= 591872`). | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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? |
||
|
|
||
| ## process.versions | ||
| <!-- YAML | ||
| added: v0.2.0 | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| 'use strict'; | ||
| require('../common'); | ||
|
|
||
| const assert = require('assert'); | ||
|
|
||
| // eslint-disable-next-line prefer-const | ||
| let [major, minor, patch] = process.version.split('.'); | ||
| major = major.slice(1); | ||
| patch = patch.slice('-')[0]; | ||
|
|
||
| assert.strictEqual( | ||
| (major << 16) + (minor << 8) + +patch, process.computedVersion); |
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.releasealso to avoid adding anything new to theprocessobject.