src: create a getter for kernel version · nodejs/node@258a80d
@@ -76,7 +76,7 @@ static void GetHostname(const FunctionCallbackInfo<Value>& args) {
7676}
7777787879-static void GetOSType(const FunctionCallbackInfo<Value>& args) {
79+static void GetOSInformation(const FunctionCallbackInfo<Value>& args) {
8080 Environment* env = Environment::GetCurrent(args);
8181uv_utsname_t info;
8282int err = uv_os_uname(&info);
@@ -87,26 +87,16 @@ static void GetOSType(const FunctionCallbackInfo<Value>& args) {
8787return args.GetReturnValue().SetUndefined();
8888 }
898990- args.GetReturnValue().Set(
91-String::NewFromUtf8(env->isolate(), info.sysname, NewStringType::kNormal)
92- .ToLocalChecked());
93-}
94-95-96-static void GetOSRelease(const FunctionCallbackInfo<Value>& args) {
97- Environment* env = Environment::GetCurrent(args);
98-uv_utsname_t info;
99-int err = uv_os_uname(&info);
90+// [sysname, version, release]
91+ Local<Value> osInformation[] = {
92+String::NewFromUtf8(env->isolate(), info.sysname).ToLocalChecked(),
93+String::NewFromUtf8(env->isolate(), info.version).ToLocalChecked(),
94+String::NewFromUtf8(env->isolate(), info.release).ToLocalChecked()
95+ };
10096101-if (err != 0) {
102-CHECK_GE(args.Length(), 1);
103- env->CollectUVExceptionInfo(args[args.Length() - 1], err, "uv_os_uname");
104-return args.GetReturnValue().SetUndefined();
105- }
106-107- args.GetReturnValue().Set(
108-String::NewFromUtf8(env->isolate(), info.release, NewStringType::kNormal)
109- .ToLocalChecked());
97+ args.GetReturnValue().Set(Array::New(env->isolate(),
98+ osInformation,
99+arraysize(osInformation)));
110100}
111101112102@@ -398,8 +388,7 @@ void Initialize(Local<Object> target,
398388 env->SetMethod(target, "getTotalMem", GetTotalMemory);
399389 env->SetMethod(target, "getFreeMem", GetFreeMemory);
400390 env->SetMethod(target, "getCPUs", GetCPUInfo);
401- env->SetMethod(target, "getOSType", GetOSType);
402- env->SetMethod(target, "getOSRelease", GetOSRelease);
391+ env->SetMethod(target, "getOSInformation", GetOSInformation);
403392 env->SetMethod(target, "getInterfaceAddresses", GetInterfaceAddresses);
404393 env->SetMethod(target, "getHomeDirectory", GetHomeDirectory);
405394 env->SetMethod(target, "getUserInfo", GetUserInfo);