summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/node.cc3
-rw-r--r--src/node_api.cc14
-rw-r--r--src/node_api.h4
-rw-r--r--src/node_api_types.h7
-rw-r--r--src/node_version.h4
5 files changed, 31 insertions, 1 deletions
diff --git a/src/node.cc b/src/node.cc
index bfd1eeb954..be1705503f 100644
--- a/src/node.cc
+++ b/src/node.cc
@@ -3266,7 +3266,8 @@ void SetupProcessObject(Environment* env,
// process.release
Local<Object> release = Object::New(env->isolate());
READONLY_PROPERTY(process, "release", release);
- READONLY_PROPERTY(release, "name", OneByteString(env->isolate(), "node"));
+ READONLY_PROPERTY(release, "name",
+ OneByteString(env->isolate(), NODE_RELEASE));
// if this is a release build and no explicit base has been set
// substitute the standard release download URL
diff --git a/src/node_api.cc b/src/node_api.cc
index 32acced231..b84a33e510 100644
--- a/src/node_api.cc
+++ b/src/node_api.cc
@@ -3119,6 +3119,20 @@ napi_status napi_get_version(napi_env env, uint32_t* result) {
return napi_clear_last_error(env);
}
+napi_status napi_get_node_version(napi_env env,
+ const napi_node_version** result) {
+ CHECK_ENV(env);
+ CHECK_ARG(env, result);
+ static const napi_node_version version = {
+ NODE_MAJOR_VERSION,
+ NODE_MINOR_VERSION,
+ NODE_PATCH_VERSION,
+ NODE_RELEASE
+ };
+ *result = &version;
+ return napi_clear_last_error(env);
+}
+
namespace uvimpl {
static napi_status ConvertUVErrorCode(int code) {
diff --git a/src/node_api.h b/src/node_api.h
index cf4128be21..0cf0ba0469 100644
--- a/src/node_api.h
+++ b/src/node_api.h
@@ -536,6 +536,10 @@ NAPI_EXTERN napi_status napi_cancel_async_work(napi_env env,
// version management
NAPI_EXTERN napi_status napi_get_version(napi_env env, uint32_t* result);
+NAPI_EXTERN
+napi_status napi_get_node_version(napi_env env,
+ const napi_node_version** version);
+
EXTERN_C_END
#endif // SRC_NODE_API_H_
diff --git a/src/node_api_types.h b/src/node_api_types.h
index 43102c519c..0bdc377c8f 100644
--- a/src/node_api_types.h
+++ b/src/node_api_types.h
@@ -102,4 +102,11 @@ typedef struct {
napi_status error_code;
} napi_extended_error_info;
+typedef struct {
+ uint32_t major;
+ uint32_t minor;
+ uint32_t patch;
+ const char* release;
+} napi_node_version;
+
#endif // SRC_NODE_API_TYPES_H_
diff --git a/src/node_version.h b/src/node_version.h
index a35d905595..339e1cd425 100644
--- a/src/node_version.h
+++ b/src/node_version.h
@@ -33,6 +33,10 @@
#define NODE_STRINGIFY_HELPER(n) #n
#endif
+#ifndef NODE_RELEASE
+#define NODE_RELEASE "node"
+#endif
+
#ifndef NODE_TAG
# if NODE_VERSION_IS_RELEASE
# define NODE_TAG ""