Skip to content

Commit

Permalink
src: add process.release.lts property
Browse files Browse the repository at this point in the history
Reviewed-By: James M Snell <[email protected]>
PR-URL: #3212
  • Loading branch information
rvagg committed Oct 18, 2016
1 parent c947d44 commit 455272a
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 0 deletions.
6 changes: 6 additions & 0 deletions doc/api/process.md
Original file line number Diff line number Diff line change
Expand Up @@ -1271,6 +1271,12 @@ tarball.

* `name` {String} A value that will always be `'node'` for Node.js. For
legacy io.js releases, this will be `'io.js'`.
* `lts`: a string with a value indicating the _codename_ of the LTS (Long-term
Support) line the current release is part of. This property only exists for
LTS releases and is `undefined` for all other release types, including stable
releases. Current 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.
* `sourceUrl` {String} an absolute URL pointing to a `_.tar.gz_` file containing
the source code of the current release.
* `headersUrl`{String} an absolute URL pointing to a `_.tar.gz_` file containing
Expand Down
5 changes: 5 additions & 0 deletions src/node.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3167,6 +3167,11 @@ void SetupProcessObject(Environment* env,
READONLY_PROPERTY(process, "release", release);
READONLY_PROPERTY(release, "name", OneByteString(env->isolate(), "node"));

#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
Expand Down
16 changes: 16 additions & 0 deletions test/parallel/test-process-release.js
Original file line number Diff line number Diff line change
@@ -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);
}

0 comments on commit 455272a

Please sign in to comment.