From a04d9ef35b37d53f40f28fb4862416675b4d17c1 Mon Sep 17 00:00:00 2001 From: Milan Burda Date: Mon, 18 Feb 2019 13:59:48 +0100 Subject: [PATCH] feat: add process.getSystemVersion() (#16599) --- atom/common/api/atom_bindings.cc | 2 ++ docs/api/process.md | 12 ++++++++++++ spec/api-process-spec.js | 6 ++++++ 3 files changed, 20 insertions(+) diff --git a/atom/common/api/atom_bindings.cc b/atom/common/api/atom_bindings.cc index 850a9d155906..0382577ddd10 100644 --- a/atom/common/api/atom_bindings.cc +++ b/atom/common/api/atom_bindings.cc @@ -73,6 +73,8 @@ void AtomBindings::BindProcess(v8::Isolate* isolate, process->SetMethod("getHeapStatistics", &GetHeapStatistics); process->SetMethod("getProcessMemoryInfo", &GetProcessMemoryInfo); process->SetMethod("getSystemMemoryInfo", &GetSystemMemoryInfo); + process->SetMethod("getSystemVersion", + &base::SysInfo::OperatingSystemVersion); process->SetMethod("getIOCounters", &GetIOCounters); process->SetMethod("getCPUUsage", base::Bind(&AtomBindings::GetCPUUsage, base::Unretained(metrics))); diff --git a/docs/api/process.md b/docs/api/process.md index 4f92c7737bca..5f74a2edba54 100644 --- a/docs/api/process.md +++ b/docs/api/process.md @@ -17,6 +17,7 @@ In sandboxed renderers the `process` object contains only a subset of the APIs: - `getHeapStatistics()` - `getProcessMemoryInfo()` - `getSystemMemoryInfo()` +- `getSystemVersion()` - `getCPUUsage()` - `getIOCounters()` - `argv` @@ -206,6 +207,17 @@ Returns `Object`: Returns an object giving memory usage statistics about the entire system. Note that all statistics are reported in Kilobytes. +### `process.getSystemVersion()` + +Returns `String` - The version of the host operating system. + +Examples: +- macOS: `10.13.6` +- Windows: `10.0.17763` +- Linux: `4.15.0-45-generic` + +**Note:** It returns the actual operating system version instead of kernel version on macOS unlike `os.release()`. + ### `process.takeHeapSnapshot(filePath)` * `filePath` String - Path to the output file. diff --git a/spec/api-process-spec.js b/spec/api-process-spec.js index 6c6452892f4a..9a4664db7407 100644 --- a/spec/api-process-spec.js +++ b/spec/api-process-spec.js @@ -59,6 +59,12 @@ describe('process module', () => { }) }) + describe('process.getSystemVersion()', () => { + it('returns a string', () => { + expect(process.getSystemVersion()).to.be.a('string') + }) + }) + describe('process.getHeapStatistics()', () => { it('returns heap statistics object', () => { const heapStats = process.getHeapStatistics()