@@ -76,7 +76,7 @@ static void GetHostname(const FunctionCallbackInfo<Value>& args) {
7676}
7777
7878
79- static void GetOSType (const FunctionCallbackInfo<Value>& args) {
79+ static void GetOSInformation (const FunctionCallbackInfo<Value>& args) {
8080 Environment* env = Environment::GetCurrent (args);
8181 uv_utsname_t info;
8282 int err = uv_os_uname (&info);
@@ -87,26 +87,19 @@ static void GetOSType(const FunctionCallbackInfo<Value>& args) {
8787 return args.GetReturnValue ().SetUndefined ();
8888 }
8989
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);
100-
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 ());
90+ // [sysname, version, release]
91+ Local<Value> osInformation[] = {
92+ String::NewFromUtf8 (
93+ env->isolate (), info.sysname , NewStringType::kNormal ).ToLocalChecked (),
94+ String::NewFromUtf8 (
95+ env->isolate (), info.version , NewStringType::kNormal ).ToLocalChecked (),
96+ String::NewFromUtf8 (
97+ env->isolate (), info.release , NewStringType::kNormal ).ToLocalChecked ()
98+ };
99+
100+ args.GetReturnValue ().Set (Array::New (env->isolate (),
101+ osInformation,
102+ arraysize (osInformation)));
110103}
111104
112105
@@ -398,8 +391,7 @@ void Initialize(Local<Object> target,
398391 env->SetMethod (target, " getTotalMem" , GetTotalMemory);
399392 env->SetMethod (target, " getFreeMem" , GetFreeMemory);
400393 env->SetMethod (target, " getCPUs" , GetCPUInfo);
401- env->SetMethod (target, " getOSType" , GetOSType);
402- env->SetMethod (target, " getOSRelease" , GetOSRelease);
394+ env->SetMethod (target, " getOSInformation" , GetOSInformation);
403395 env->SetMethod (target, " getInterfaceAddresses" , GetInterfaceAddresses);
404396 env->SetMethod (target, " getHomeDirectory" , GetHomeDirectory);
405397 env->SetMethod (target, " getUserInfo" , GetUserInfo);
0 commit comments