Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

src: process release lts property #16656

Merged
merged 2 commits into from
Nov 2, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion doc/api/process.md
Original file line number Diff line number Diff line change
Expand Up @@ -1444,7 +1444,11 @@ tarball.
compiling Node.js native add-ons. _This property is only present on Windows
builds of Node.js and will be missing on all other platforms._
* `lts` {string} a string label identifying the [LTS][] label for this release.
If the Node.js release is not an LTS release, this will be `undefined`.
This property only exists for LTS releases and is `undefined` for all other
release types, including _Current_ releases. Currently the 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.
- `'Carbon'` for the v8.x LTS line beginning with v8.9.1.

For example:

Expand Down
5 changes: 5 additions & 0 deletions src/node.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3496,6 +3496,11 @@ void SetupProcessObject(Environment* env,
READONLY_PROPERTY(release, "name",
OneByteString(env->isolate(), NODE_RELEASE));

#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
20 changes: 20 additions & 0 deletions test/parallel/test-process-release.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
'use strict';

require('../common');

const assert = require('assert');
const versionParts = process.versions.node.split('.');

assert.strictEqual(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.strictEqual(process.release.lts, 'Argon');
} else if (versionParts[0] === '6' && versionParts[1] >= 9) {
assert.strictEqual(process.release.lts, 'Boron');
} else if (versionParts[0] === '8' && versionParts[1] >= 9) {
assert.strictEqual(process.release.lts, 'Carbon');
} else {
assert.strictEqual(process.release.lts, undefined);
}