Skip to content

Commit 0668a75

Browse files
mhdawsonevanlucas
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. 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 d8ac817 commit 0668a75

File tree

4 files changed

+10
-3
lines changed

4 files changed

+10
-3
lines changed

src/node.cc

+6
Original file line numberDiff line numberDiff line change
@@ -3368,6 +3368,12 @@ void SetupProcessObject(Environment* env,
33683368
"nghttp2",
33693369
FIXED_ONE_BYTE_STRING(env->isolate(), NGHTTP2_VERSION));
33703370

3371+
const char node_napi_version[] = NODE_STRINGIFY(NAPI_VERSION);
3372+
READONLY_PROPERTY(
3373+
versions,
3374+
"napi",
3375+
FIXED_ONE_BYTE_STRING(env->isolate(), node_napi_version));
3376+
33713377
// process._promiseRejectEvent
33723378
Local<Object> promiseRejectEvent = Object::New(env->isolate());
33733379
READONLY_DONT_ENUM_PROPERTY(process,

src/node_api.cc

-2
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@
1818
#include "node_api.h"
1919
#include "node_internals.h"
2020

21-
#define NAPI_VERSION 2
22-
2321
static
2422
napi_status napi_set_last_error(napi_env env, napi_status error_code,
2523
uint32_t engine_error_code = 0,

src/node_version.h

+3
Original file line numberDiff line numberDiff line change
@@ -108,4 +108,7 @@
108108
*/
109109
#define NODE_MODULE_VERSION 59
110110

111+
// the NAPI_VERSION provided by this version of the runtime
112+
#define NAPI_VERSION 2
113+
111114
#endif // SRC_NODE_VERSION_H_

test/parallel/test-process-versions.js

+1-1
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', 'nghttp2'];
6+
'uv', 'v8', 'zlib', 'nghttp2', 'napi'];
77

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

0 commit comments

Comments
 (0)