feat: add process.getSystemVersion() (#16599)

This commit is contained in:
Milan Burda 2019-02-18 13:59:48 +01:00 committed by Charles Kerr
parent eaa0e28396
commit a04d9ef35b
3 changed files with 20 additions and 0 deletions

View file

@ -73,6 +73,8 @@ void AtomBindings::BindProcess(v8::Isolate* isolate,
process->SetMethod("getHeapStatistics", &GetHeapStatistics); process->SetMethod("getHeapStatistics", &GetHeapStatistics);
process->SetMethod("getProcessMemoryInfo", &GetProcessMemoryInfo); process->SetMethod("getProcessMemoryInfo", &GetProcessMemoryInfo);
process->SetMethod("getSystemMemoryInfo", &GetSystemMemoryInfo); process->SetMethod("getSystemMemoryInfo", &GetSystemMemoryInfo);
process->SetMethod("getSystemVersion",
&base::SysInfo::OperatingSystemVersion);
process->SetMethod("getIOCounters", &GetIOCounters); process->SetMethod("getIOCounters", &GetIOCounters);
process->SetMethod("getCPUUsage", base::Bind(&AtomBindings::GetCPUUsage, process->SetMethod("getCPUUsage", base::Bind(&AtomBindings::GetCPUUsage,
base::Unretained(metrics))); base::Unretained(metrics)));

View file

@ -17,6 +17,7 @@ In sandboxed renderers the `process` object contains only a subset of the APIs:
- `getHeapStatistics()` - `getHeapStatistics()`
- `getProcessMemoryInfo()` - `getProcessMemoryInfo()`
- `getSystemMemoryInfo()` - `getSystemMemoryInfo()`
- `getSystemVersion()`
- `getCPUUsage()` - `getCPUUsage()`
- `getIOCounters()` - `getIOCounters()`
- `argv` - `argv`
@ -206,6 +207,17 @@ Returns `Object`:
Returns an object giving memory usage statistics about the entire system. Note Returns an object giving memory usage statistics about the entire system. Note
that all statistics are reported in Kilobytes. 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)` ### `process.takeHeapSnapshot(filePath)`
* `filePath` String - Path to the output file. * `filePath` String - Path to the output file.

View file

@ -59,6 +59,12 @@ describe('process module', () => {
}) })
}) })
describe('process.getSystemVersion()', () => {
it('returns a string', () => {
expect(process.getSystemVersion()).to.be.a('string')
})
})
describe('process.getHeapStatistics()', () => { describe('process.getHeapStatistics()', () => {
it('returns heap statistics object', () => { it('returns heap statistics object', () => {
const heapStats = process.getHeapStatistics() const heapStats = process.getHeapStatistics()