Skip to content

Commit 42b936e

Browse files
rvaggjasnell
authored andcommitted
src: add process.release.lts property
Reviewed-By: James M Snell <jasnell@gmail.com> PR-URL: #3212
1 parent 7472713 commit 42b936e

File tree

4 files changed

+27
-0
lines changed

4 files changed

+27
-0
lines changed

doc/api/process.markdown

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -689,6 +689,11 @@ for the source tarball and headers-only tarball.
689689

690690
* `name`: a string with a value that will always be `"node"` for Node.js. For
691691
legacy io.js releases, this will be `"io.js"`.
692+
* `lts`: a string with a value indicating the _codename_ of the LTS (Long-term
693+
Support) line the current release is part of. This property only exists for
694+
LTS releases and is `undefined` for all other release types, including stable
695+
releases. Current valid values are:
696+
- `"Argon"` for the v4.x LTS line beginning with v4.2.0.
692697
* `sourceUrl`: a complete URL pointing to a _.tar.gz_ file containing the
693698
source of the current release.
694699
* `headersUrl`: a complete URL pointing to a _.tar.gz_ file containing only

src/node.cc

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

2777+
#if NODE_VERSION_IS_LTS
2778+
READONLY_PROPERTY(release, "lts",
2779+
OneByteString(env->isolate(), NODE_VERSION_LTS_CODENAME));
2780+
#endif
2781+
27772782
// if this is a release build and no explicit base has been set
27782783
// substitute the standard release download URL
27792784
#ifndef NODE_RELEASE_URLBASE

src/node_version.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
#define NODE_MINOR_VERSION 1
66
#define NODE_PATCH_VERSION 3
77

8+
#define NODE_VERSION_IS_LTS 1
9+
#define NODE_VERSION_LTS_CODENAME "Argon"
10+
811
#define NODE_VERSION_IS_RELEASE 0
912

1013
#ifndef NODE_STRINGIFY

test/parallel/test-process-release.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
'use strict';
2+
const common = 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 {
13+
assert.strictEqual(process.release.lts, undefined);
14+
}

0 commit comments

Comments
 (0)