Skip to content

Commit 455272a

Browse files
committed
src: add process.release.lts property
Reviewed-By: James M Snell <jasnell@gmail.com> PR-URL: #3212
1 parent c947d44 commit 455272a

File tree

3 files changed

+27
-0
lines changed

3 files changed

+27
-0
lines changed

doc/api/process.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1271,6 +1271,12 @@ tarball.
12711271

12721272
* `name` {String} A value that will always be `'node'` for Node.js. For
12731273
legacy io.js releases, this will be `'io.js'`.
1274+
* `lts`: a string with a value indicating the _codename_ of the LTS (Long-term
1275+
Support) line the current release is part of. This property only exists for
1276+
LTS releases and is `undefined` for all other release types, including stable
1277+
releases. Current valid values are:
1278+
- `"Argon"` for the v4.x LTS line beginning with v4.2.0.
1279+
- `"Boron"` for the v6.x LTS line beginning with v6.9.0.
12741280
* `sourceUrl` {String} an absolute URL pointing to a `_.tar.gz_` file containing
12751281
the source code of the current release.
12761282
* `headersUrl`{String} an absolute URL pointing to a `_.tar.gz_` file containing

src/node.cc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3167,6 +3167,11 @@ void SetupProcessObject(Environment* env,
31673167
READONLY_PROPERTY(process, "release", release);
31683168
READONLY_PROPERTY(release, "name", OneByteString(env->isolate(), "node"));
31693169

3170+
#if NODE_VERSION_IS_LTS
3171+
READONLY_PROPERTY(release, "lts",
3172+
OneByteString(env->isolate(), NODE_VERSION_LTS_CODENAME));
3173+
#endif
3174+
31703175
// if this is a release build and no explicit base has been set
31713176
// substitute the standard release download URL
31723177
#ifndef NODE_RELEASE_URLBASE
Lines changed: 16 additions & 0 deletions
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)