Skip to content

Commit 853b4d5

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: #19265 PR-URL: #18067 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Minwoo Jung <minwoo@nodesource.com> Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com> Reviewed-By: Tobias Nießn <tniessen@tnie.de> Reviewed-By: Richard Lau <riclau@uk.ibm.com>
1 parent 48be8a4 commit 853b4d5

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
@@ -3374,6 +3374,12 @@ void SetupProcessObject(Environment* env,
33743374
"nghttp2",
33753375
FIXED_ONE_BYTE_STRING(env->isolate(), NGHTTP2_VERSION));
33763376

3377+
const char node_napi_version[] = NODE_STRINGIFY(NAPI_VERSION);
3378+
READONLY_PROPERTY(
3379+
versions,
3380+
"napi",
3381+
FIXED_ONE_BYTE_STRING(env->isolate(), node_napi_version));
3382+
33773383
// process._promiseRejectEvent
33783384
Local<Object> promiseRejectEvent = Object::New(env->isolate());
33793385
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
@@ -107,4 +107,7 @@
107107
*/
108108
#define NODE_MODULE_VERSION 57
109109

110+
// the NAPI_VERSION provided by this version of the runtime
111+
#define NAPI_VERSION 2
112+
110113
#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)