diff options
author | Rod Vagg <rod@vagg.org> | 2015-10-06 23:31:14 +1100 |
---|---|---|
committer | Jeremiah Senkpiel <fishrock123@rocketmail.com> | 2017-11-02 09:28:41 -0700 |
commit | bf26b96fd615fa335c7ed9f1c99afff9edf344eb (patch) | |
tree | 563809be4260991ae93e6e86c3b5bdfaed4676d1 | |
parent | 40d82118d89ed0987bb6711964aaa27e732170f0 (diff) | |
download | node-new-bf26b96fd615fa335c7ed9f1c99afff9edf344eb.tar.gz |
src: add 'dynamic' process.release.lts property
This makes the process.release.lts property configurable by a constant.
This ref is the original PR to v6.x.
Refs: https://github.com/nodejs/node/pull/3212
Conflicts:
doc/api/process.md
PR-URL: https://github.com/nodejs/node/pull/16656
Reviewed-By: Myles Borins <myles.borins@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
Reviewed-By: Anatoli Papirovski <apapirovski@mac.com>
-rw-r--r-- | doc/api/process.md | 6 | ||||
-rw-r--r-- | src/node.cc | 5 | ||||
-rw-r--r-- | test/parallel/test-process-release.js | 16 |
3 files changed, 26 insertions, 1 deletions
diff --git a/doc/api/process.md b/doc/api/process.md index 959283b797..7a005503c9 100644 --- a/doc/api/process.md +++ b/doc/api/process.md @@ -1396,7 +1396,11 @@ tarball. compiling Node.js native add-ons. _This property is only present on Windows builds of Node.js and will be missing on all other platforms._ * `lts` {string} a string label identifying the [LTS][] label for this release. - If the Node.js release is not an LTS release, this will be `undefined`. + This property only exists for LTS releases and is `undefined` for all other + release types, including _Current_ releases. Currently the valid values are: + - `'Argon'` for the v4.x LTS line beginning with v4.2.0. + - `'Boron'` for the v6.x LTS line beginning with v6.9.0. + - `'Carbon'` for the v8.x LTS line beginning with v8.9.1. For example: diff --git a/src/node.cc b/src/node.cc index 7a7db9140f..e6e3e02c98 100644 --- a/src/node.cc +++ b/src/node.cc @@ -3458,6 +3458,11 @@ void SetupProcessObject(Environment* env, READONLY_PROPERTY(release, "name", OneByteString(env->isolate(), NODE_RELEASE)); +#if NODE_VERSION_IS_LTS + READONLY_PROPERTY(release, "lts", + OneByteString(env->isolate(), NODE_VERSION_LTS_CODENAME)); +#endif + // if this is a release build and no explicit base has been set // substitute the standard release download URL #ifndef NODE_RELEASE_URLBASE diff --git a/test/parallel/test-process-release.js b/test/parallel/test-process-release.js new file mode 100644 index 0000000000..5d5228af72 --- /dev/null +++ b/test/parallel/test-process-release.js @@ -0,0 +1,16 @@ +'use strict'; +require('../common'); +const assert = require('assert'); +const versionParts = process.versions.node.split('.'); + +assert.equal(process.release.name, 'node'); + +// it's expected that future LTS release lines will have additional +// branches in here +if (versionParts[0] === '4' && versionParts[1] >= 2) { + assert.equal(process.release.lts, 'Argon'); +} else if (versionParts[0] === '6' && versionParts[1] >= 9) { + assert.equal(process.release.lts, 'Boron'); +} else { + assert.strictEqual(process.release.lts, undefined); +} |