@@ -75,8 +75,7 @@ static void GetHostname(const FunctionCallbackInfo<Value>& args) {
75
75
.ToLocalChecked ());
76
76
}
77
77
78
-
79
- static void GetOSType (const FunctionCallbackInfo<Value>& args) {
78
+ static void GetOSInformation (const FunctionCallbackInfo<Value>& args) {
80
79
Environment* env = Environment::GetCurrent (args);
81
80
uv_utsname_t info;
82
81
int err = uv_os_uname (&info);
@@ -87,29 +86,18 @@ static void GetOSType(const FunctionCallbackInfo<Value>& args) {
87
86
return args.GetReturnValue ().SetUndefined ();
88
87
}
89
88
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
- }
89
+ // [sysname, version, release]
90
+ Local<Value> osInformation[] = {
91
+ String::NewFromUtf8 (env->isolate (), info.sysname ).ToLocalChecked (),
92
+ String::NewFromUtf8 (env->isolate (), info.version ).ToLocalChecked (),
93
+ String::NewFromUtf8 (env->isolate (), info.release ).ToLocalChecked ()
94
+ };
106
95
107
- args.GetReturnValue ().Set (
108
- String::NewFromUtf8 (env-> isolate (), info. release , NewStringType:: kNormal )
109
- . ToLocalChecked ( ));
96
+ args.GetReturnValue ().Set (Array::New (env-> isolate (),
97
+ osInformation,
98
+ arraysize (osInformation) ));
110
99
}
111
100
112
-
113
101
static void GetCPUInfo (const FunctionCallbackInfo<Value>& args) {
114
102
Environment* env = Environment::GetCurrent (args);
115
103
Isolate* isolate = env->isolate ();
@@ -398,13 +386,12 @@ void Initialize(Local<Object> target,
398
386
env->SetMethod (target, " getTotalMem" , GetTotalMemory);
399
387
env->SetMethod (target, " getFreeMem" , GetFreeMemory);
400
388
env->SetMethod (target, " getCPUs" , GetCPUInfo);
401
- env->SetMethod (target, " getOSType" , GetOSType);
402
- env->SetMethod (target, " getOSRelease" , GetOSRelease);
403
389
env->SetMethod (target, " getInterfaceAddresses" , GetInterfaceAddresses);
404
390
env->SetMethod (target, " getHomeDirectory" , GetHomeDirectory);
405
391
env->SetMethod (target, " getUserInfo" , GetUserInfo);
406
392
env->SetMethod (target, " setPriority" , SetPriority);
407
393
env->SetMethod (target, " getPriority" , GetPriority);
394
+ env->SetMethod (target, " getOSInformation" , GetOSInformation);
408
395
target->Set (env->context (),
409
396
FIXED_ONE_BYTE_STRING (env->isolate (), " isBigEndian" ),
410
397
Boolean::New (env->isolate (), IsBigEndian ())).Check ();
0 commit comments