Skip to content

Commit 62427bb

Browse files
mhdawsonMylesBorins
authored andcommitted
n-api: expose n-api version in process.versions
Expose n-api version in process.versions so that it is available for use in javascript by external modules like node-pre-gyp. It was previously accessible through a functon available in the N-API. Backport-PR-URL: #19447 PR-URL: #18067 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Tiancheng "Timothy" Gu <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Jeremiah Senkpiel <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Minwoo Jung <[email protected]> Reviewed-By: Gibson Fahnestock <[email protected]> Reviewed-By: Tobias Nießn <[email protected]> Reviewed-By: Richard Lau <[email protected]>
1 parent bb99f31 commit 62427bb

File tree

4 files changed

+10
-3
lines changed

4 files changed

+10
-3
lines changed

src/node.cc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3198,6 +3198,12 @@ void SetupProcessObject(Environment* env,
31983198
"modules",
31993199
FIXED_ONE_BYTE_STRING(env->isolate(), node_modules_version));
32003200

3201+
const char node_napi_version[] = NODE_STRINGIFY(NAPI_VERSION);
3202+
READONLY_PROPERTY(
3203+
versions,
3204+
"napi",
3205+
FIXED_ONE_BYTE_STRING(env->isolate(), node_napi_version));
3206+
32013207
// process._promiseRejectEvent
32023208
Local<Object> promiseRejectEvent = Object::New(env->isolate());
32033209
READONLY_DONT_ENUM_PROPERTY(process,

src/node_api.cc

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@
2222
#include "node_api_backport.h"
2323
#include "util.h"
2424

25-
#define NAPI_VERSION 2
26-
2725
static
2826
napi_status napi_set_last_error(napi_env env, napi_status error_code,
2927
uint32_t engine_error_code = 0,

src/node_version.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,4 +61,7 @@
6161
*/
6262
#define NODE_MODULE_VERSION 48 /* Node.js v6.0.0 */
6363

64+
// the NAPI_VERSION provided by this version of the runtime
65+
#define NAPI_VERSION 2
66+
6467
#endif // SRC_NODE_VERSION_H_

test/parallel/test-process-versions.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ const common = require('../common');
33
const assert = require('assert');
44

55
const expected_keys = ['ares', 'http_parser', 'modules', 'node',
6-
'uv', 'v8', 'zlib'];
6+
'uv', 'v8', 'zlib', 'napi'];
77

88
if (common.hasCrypto) {
99
expected_keys.push('openssl');

0 commit comments

Comments
 (0)