From 42b936e78ddb0131ad620c8cc87acf1f1f5325d9 Mon Sep 17 00:00:00 2001 From: Rod Vagg Date: Tue, 6 Oct 2015 23:31:14 +1100 Subject: [PATCH] src: add process.release.lts property Reviewed-By: James M Snell PR-URL: https://github.com/nodejs/node/pull/3212 --- doc/api/process.markdown | 5 +++++ src/node.cc | 5 +++++ src/node_version.h | 3 +++ test/parallel/test-process-release.js | 14 ++++++++++++++ 4 files changed, 27 insertions(+) create mode 100644 test/parallel/test-process-release.js diff --git a/doc/api/process.markdown b/doc/api/process.markdown index 71953766d339aa..8b2972c2fa948e 100644 --- a/doc/api/process.markdown +++ b/doc/api/process.markdown @@ -689,6 +689,11 @@ for the source tarball and headers-only tarball. * `name`: a string with 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. * `sourceUrl`: a complete URL pointing to a _.tar.gz_ file containing the source of the current release. * `headersUrl`: a complete URL pointing to a _.tar.gz_ file containing only diff --git a/src/node.cc b/src/node.cc index 90d10883acd807..b80996e233a760 100644 --- a/src/node.cc +++ b/src/node.cc @@ -2774,6 +2774,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 diff --git a/src/node_version.h b/src/node_version.h index 694fbc0bbd309b..1364b56ff47c89 100644 --- a/src/node_version.h +++ b/src/node_version.h @@ -5,6 +5,9 @@ #define NODE_MINOR_VERSION 1 #define NODE_PATCH_VERSION 3 +#define NODE_VERSION_IS_LTS 1 +#define NODE_VERSION_LTS_CODENAME "Argon" + #define NODE_VERSION_IS_RELEASE 0 #ifndef NODE_STRINGIFY diff --git a/test/parallel/test-process-release.js b/test/parallel/test-process-release.js new file mode 100644 index 00000000000000..af21daf78b61b2 --- /dev/null +++ b/test/parallel/test-process-release.js @@ -0,0 +1,14 @@ +'use strict'; +const common = 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 { + assert.strictEqual(process.release.lts, undefined); +}