Skip to content

Commit c40b3c6

Browse files
rvaggcjihrig
authored andcommitted
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: #3212 Conflicts: doc/api/process.md PR-URL: #16656 Reviewed-By: Myles Borins <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Gireesh Punathil <[email protected]> Reviewed-By: Anatoli Papirovski <[email protected]>
1 parent 90e8e81 commit c40b3c6

File tree

3 files changed

+26
-1
lines changed

3 files changed

+26
-1
lines changed

doc/api/process.md

+5-1
Original file line numberDiff line numberDiff line change
@@ -1444,7 +1444,11 @@ tarball.
14441444
compiling Node.js native add-ons. _This property is only present on Windows
14451445
builds of Node.js and will be missing on all other platforms._
14461446
* `lts` {string} a string label identifying the [LTS][] label for this release.
1447-
If the Node.js release is not an LTS release, this will be `undefined`.
1447+
This property only exists for LTS releases and is `undefined` for all other
1448+
release types, including _Current_ releases. Currently the valid values are:
1449+
- `'Argon'` for the v4.x LTS line beginning with v4.2.0.
1450+
- `'Boron'` for the v6.x LTS line beginning with v6.9.0.
1451+
- `'Carbon'` for the v8.x LTS line beginning with v8.9.1.
14481452

14491453
For example:
14501454

src/node.cc

+5
Original file line numberDiff line numberDiff line change
@@ -3496,6 +3496,11 @@ void SetupProcessObject(Environment* env,
34963496
READONLY_PROPERTY(release, "name",
34973497
OneByteString(env->isolate(), NODE_RELEASE));
34983498

3499+
#if NODE_VERSION_IS_LTS
3500+
READONLY_PROPERTY(release, "lts",
3501+
OneByteString(env->isolate(), NODE_VERSION_LTS_CODENAME));
3502+
#endif
3503+
34993504
// if this is a release build and no explicit base has been set
35003505
// substitute the standard release download URL
35013506
#ifndef NODE_RELEASE_URLBASE

test/parallel/test-process-release.js

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
'use strict';
2+
require('../common');
3+
const assert = require('assert');
4+
const versionParts = process.versions.node.split('.');
5+
6+
assert.equal(process.release.name, 'node');
7+
8+
// it's expected that future LTS release lines will have additional
9+
// branches in here
10+
if (versionParts[0] === '4' && versionParts[1] >= 2) {
11+
assert.equal(process.release.lts, 'Argon');
12+
} else if (versionParts[0] === '6' && versionParts[1] >= 9) {
13+
assert.equal(process.release.lts, 'Boron');
14+
} else {
15+
assert.strictEqual(process.release.lts, undefined);
16+
}

0 commit comments

Comments
 (0)