Skip to content

Commit

Permalink
fix: get node version from macros
Browse files Browse the repository at this point in the history
PR-URL: #121
Reviewed-BY: hyj1991 <[email protected]>
  • Loading branch information
legendecas authored Dec 27, 2021
1 parent 2fbf5f8 commit f26e918
Showing 1 changed file with 2 additions and 17 deletions.
19 changes: 2 additions & 17 deletions src/library/common.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,25 +18,10 @@ using v8::String;
using v8::Value;

static time_t load_time;
static string global_node_version_string;

static void SetGlobalNodeVersion() {
HandleScope scope;
Local<Value> global_process =
Get(GetCurrentContext()->Global(), New("process").ToLocalChecked())
.ToLocalChecked();
Local<Object> process_object = To<Object>(global_process).ToLocalChecked();
Local<Value> node_version_value =
Get(process_object, New("version").ToLocalChecked()).ToLocalChecked();
Local<String> node_version_string =
To<String>(node_version_value).ToLocalChecked();
Utf8String node_version(node_version_string);
global_node_version_string = (*node_version);
}
static string global_node_version_string = NODE_VERSION;

void InitGlobalVariables() {
time(&load_time);
SetGlobalNodeVersion();
}

unsigned long GetUptime() {
Expand All @@ -53,4 +38,4 @@ string GetStartTime(string format) {
}

string GetGlobalNodeVersion() { return global_node_version_string; }
} // namespace xprofiler
} // namespace xprofiler

0 comments on commit f26e918

Please sign in to comment.