Skip to content

Commit fccff27

Browse files
rvaggjasnell
authored andcommitted
Revert "process: add version constants and compare"
This reverts commit 91e0f8d. PR-URL: #20062 Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com> Reviewed-By: Evan Lucas <evanlucas@me.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com> Reviewed-By: Ali Ijaz Sheikh <ofrobots@google.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de>
1 parent 6e05a96 commit fccff27

File tree

5 files changed

+5
-124
lines changed

5 files changed

+5
-124
lines changed

doc/api/process.md

Lines changed: 3 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1482,9 +1482,6 @@ changes:
14821482
- version: v4.2.0
14831483
pr-url: https://github.com/nodejs/node/pull/3212
14841484
description: The `lts` property is now supported.
1485-
- version: REPLACEME
1486-
pr-url: https://github.com/nodejs/node/pull/19587
1487-
description: Add SemVer properties.
14881485
-->
14891486

14901487
* {Object}
@@ -1513,10 +1510,6 @@ tarball.
15131510
- `'Argon'` for the 4.x LTS line beginning with 4.2.0.
15141511
- `'Boron'` for the 6.x LTS line beginning with 6.9.0.
15151512
- `'Carbon'` for the 8.x LTS line beginning with 8.9.1.
1516-
* `majorVersion` {number} The major version of this release.
1517-
* `minorVersion` {number} The minor version of this release.
1518-
* `patchVersion` {number} The patch version of this release.
1519-
* `prereleaseTag` {string} The SemVer pre-release tag for Node.js.
15201513

15211514
<!-- eslint-skip -->
15221515
```js
@@ -1525,34 +1518,13 @@ tarball.
15251518
lts: 'Argon',
15261519
sourceUrl: 'https://nodejs.org/download/release/v4.4.5/node-v4.4.5.tar.gz',
15271520
headersUrl: 'https://nodejs.org/download/release/v4.4.5/node-v4.4.5-headers.tar.gz',
1528-
libUrl: 'https://nodejs.org/download/release/v4.4.5/win-x64/node.lib',
1529-
majorVersion: 4,
1530-
minorVersion: 4,
1531-
patchVersion: 5,
1532-
prereleaseTag: '',
1533-
compareVersion: [Function: compareVersion]
1521+
libUrl: 'https://nodejs.org/download/release/v4.4.5/win-x64/node.lib'
15341522
}
15351523
```
15361524

1537-
15381525
In custom builds from non-release versions of the source tree, only the
1539-
`name` property and SemVer properties may be present. The additional properties
1540-
should not be relied upon to exist.
1541-
1542-
## process.release.compareVersion(major, minor, patch[, tag])
1543-
<!-- YAML
1544-
added: REPLACEME
1545-
-->
1546-
1547-
Perform a SemVer comparison to the release version.
1548-
1549-
* `major` {number} The major version to compare.
1550-
* `minor` {number} The minor version to compare.
1551-
* `patch` {number} The patch version to compare.
1552-
* `tag` {string} The pre-release tag to compare.
1553-
* Returns: {number} `1` if the given version is lower than the current release
1554-
version, `0` if the given version matches the process version, and `-1`
1555-
if the given version is greater than the release version.
1526+
`name` property may be present. The additional properties should not be
1527+
relied upon to exist.
15561528

15571529
## process.send(message[, sendHandle[, options]][, callback])
15581530
<!-- YAML

lib/internal/bootstrap/node.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535
setupGlobalVariables();
3636

3737
const _process = NativeModule.require('internal/process');
38-
_process.setupCompareVersion();
3938
_process.setupConfig(NativeModule._source);
4039
_process.setupSignalHandlers();
4140
_process.setupUncaughtExceptionCapture(exceptionHandlerState);

lib/internal/process.js

Lines changed: 1 addition & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -283,47 +283,6 @@ function setupUncaughtExceptionCapture(exceptionHandlerState) {
283283
};
284284
}
285285

286-
function setupCompareVersion() {
287-
const {
288-
majorVersion,
289-
minorVersion,
290-
patchVersion,
291-
prereleaseTag,
292-
} = process.release;
293-
294-
process.release.compareVersion = (major, minor, patch, tag) => {
295-
if (typeof major !== 'number')
296-
throw new ERR_INVALID_ARG_TYPE('major', 'number', major);
297-
if (typeof minor !== 'number')
298-
throw new ERR_INVALID_ARG_TYPE('minor', 'number', minor);
299-
if (typeof patch !== 'number')
300-
throw new ERR_INVALID_ARG_TYPE('patch', 'number', patch);
301-
if (tag !== undefined && typeof tag !== 'string')
302-
throw new ERR_INVALID_ARG_TYPE('tag', 'string', tag);
303-
304-
if (major > majorVersion)
305-
return -1;
306-
if (major < majorVersion)
307-
return 1;
308-
309-
if (minor > minorVersion)
310-
return -1;
311-
if (minor < minorVersion)
312-
return 1;
313-
314-
if (patch > patchVersion)
315-
return -1;
316-
if (patch < patchVersion)
317-
return 1;
318-
if (prereleaseTag)
319-
return prereleaseTag === tag ? 0 : 1;
320-
if (tag)
321-
return -1;
322-
323-
return 0;
324-
};
325-
}
326-
327286
module.exports = {
328287
setup_performance,
329288
setup_cpuUsage,
@@ -334,6 +293,5 @@ module.exports = {
334293
setupSignalHandlers,
335294
setupChannel,
336295
setupRawDebug,
337-
setupUncaughtExceptionCapture,
338-
setupCompareVersion,
296+
setupUncaughtExceptionCapture
339297
};

src/node.cc

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3017,17 +3017,6 @@ void SetupProcessObject(Environment* env,
30173017
READONLY_PROPERTY(release, "name",
30183018
OneByteString(env->isolate(), NODE_RELEASE));
30193019

3020-
READONLY_PROPERTY(release, "majorVersion",
3021-
Integer::New(env->isolate(), NODE_MAJOR_VERSION));
3022-
READONLY_PROPERTY(release, "minorVersion",
3023-
Integer::New(env->isolate(), NODE_MINOR_VERSION));
3024-
READONLY_PROPERTY(release, "patchVersion",
3025-
Integer::New(env->isolate(), NODE_PATCH_VERSION));
3026-
std::string node_tag(NODE_TAG);
3027-
READONLY_PROPERTY(release, "prereleaseTag",
3028-
OneByteString(env->isolate(), node_tag.size() > 0 ?
3029-
node_tag.substr(1).c_str() : ""));
3030-
30313020
#if NODE_VERSION_IS_LTS
30323021
READONLY_PROPERTY(release, "lts",
30333022
OneByteString(env->isolate(), NODE_VERSION_LTS_CODENAME));
Lines changed: 1 addition & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use strict';
22

3-
const common = require('../common');
3+
require('../common');
44

55
const assert = require('assert');
66
const versionParts = process.versions.node.split('.');
@@ -18,40 +18,3 @@ if (versionParts[0] === '4' && versionParts[1] >= 2) {
1818
} else {
1919
assert.strictEqual(process.release.lts, undefined);
2020
}
21-
22-
const {
23-
majorVersion: major,
24-
minorVersion: minor,
25-
patchVersion: patch,
26-
prereleaseTag: tag,
27-
compareVersion,
28-
} = process.release;
29-
30-
assert.strictEqual(compareVersion(major, minor, patch, tag), 0);
31-
32-
assert.strictEqual(compareVersion(major + 1, minor, patch, tag), -1);
33-
assert.strictEqual(compareVersion(major - 1, minor, patch, tag), 1);
34-
35-
assert.strictEqual(compareVersion(major, minor + 1, patch, tag), -1);
36-
assert.strictEqual(compareVersion(major, minor - 1, patch, tag), 1);
37-
38-
assert.strictEqual(compareVersion(major, minor, patch + 1, tag), -1);
39-
assert.strictEqual(compareVersion(major, minor, patch - 1, tag), 1);
40-
41-
if (tag)
42-
assert.strictEqual(compareVersion(major, minor, patch), 1);
43-
else
44-
assert.strictEqual(compareVersion(major, minor, patch, 'notrealtag'), -1);
45-
46-
for (const args of [
47-
['', 0, 0, ''],
48-
[0, '', 0, ''],
49-
[0, 0, '', ''],
50-
[0, 0, 0, 0],
51-
]) {
52-
common.expectsError(() => {
53-
compareVersion(...args);
54-
}, {
55-
code: 'ERR_INVALID_ARG_TYPE',
56-
});
57-
}

0 commit comments

Comments
 (0)