@@ -76,7 +76,7 @@ static void GetHostname(const FunctionCallbackInfo<Value>& args) {
76
76
}
77
77
78
78
79
- static void GetOSType (const FunctionCallbackInfo<Value>& args) {
79
+ static void GetOSInformation (const FunctionCallbackInfo<Value>& args) {
80
80
Environment* env = Environment::GetCurrent (args);
81
81
uv_utsname_t info;
82
82
int err = uv_os_uname (&info);
@@ -87,26 +87,16 @@ static void GetOSType(const FunctionCallbackInfo<Value>& args) {
87
87
return args.GetReturnValue ().SetUndefined ();
88
88
}
89
89
90
- 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
+ };
100
96
101
- 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)));
110
100
}
111
101
112
102
@@ -398,8 +388,7 @@ void Initialize(Local<Object> target,
398
388
env->SetMethod (target, " getTotalMem" , GetTotalMemory);
399
389
env->SetMethod (target, " getFreeMem" , GetFreeMemory);
400
390
env->SetMethod (target, " getCPUs" , GetCPUInfo);
401
- env->SetMethod (target, " getOSType" , GetOSType);
402
- env->SetMethod (target, " getOSRelease" , GetOSRelease);
391
+ env->SetMethod (target, " getOSInformation" , GetOSInformation);
403
392
env->SetMethod (target, " getInterfaceAddresses" , GetInterfaceAddresses);
404
393
env->SetMethod (target, " getHomeDirectory" , GetHomeDirectory);
405
394
env->SetMethod (target, " getUserInfo" , GetUserInfo);
0 commit comments