added shell (returns standard shell)

This commit is contained in:
Sebastian Hildebrandt 2016-11-23 10:31:03 +01:00
parent a4fd3e65fa
commit 1ae4ef8c08
5 changed files with 29 additions and 6 deletions

View File

@ -16,6 +16,7 @@
New Functions
- `shell`: returns standard shell e.g. /bin/bash (new in version 3.13)
- `blockDevices`: returns array of block devices like disks, partitions, raids, roms (new in version 3.10)
- `dockerContainerProcesses`: returns processes for a specific docker container (new in version 3.8)
- `versions`: returns object of versions - kernel, ssl, node, npm, ...(new in version 3.6)
@ -89,6 +90,7 @@ Other changes
| Version | Date | Comment |
| -------------- | -------------- | -------- |
| 3.13.0 | 2016-11-23 | added shell (returns standard shell) |
| 3.12.0 | 2016-11-17 | refactoring and extended currentLoad |
| 3.11.2 | 2016-11-16 | blockDevices: improved for older lsblk versions |
| 3.11.1 | 2016-11-16 | fixed small bug in blockDevices |

View File

@ -42,6 +42,7 @@ si.cpu()
### Latest Activity
- Version 3.13.0: added shell (returns standard shell)
- Version 3.12.0: refactoring and extended currentLoad (better OSX coverage and added irq load).
- Version 3.11.0: blockDevices now also for OSX and also extended (+ label, model, serial, protocol).
- Version 3.10.0: added blockDevices (list of disks, partitions, raids and roms).
@ -117,6 +118,7 @@ This library is splitted in several sections:
| - hostname | X | X | same as os.hostname() |
| - logofile | X | X | e.g. 'apple', 'debian', 'fedora', ... |
| si.versions(cb) | X | X | Version information (kernel, ssl, node, ...) |
| si.shell(cb) | X | X | standard shell |
| si.cpu(cb) | X | X | CPU information|
| - manufacturer | X | X | e.g. 'Intel(R)' |
| - brand | X | X | e.g. 'Core(TM)2 Duo' |

View File

@ -7,11 +7,6 @@
// Copyright: (c) 2014 - 2016
// Author: Sebastian Hildebrandt
// ----------------------------------------------------------------------------------
// Contributors: Guillaume Legrain (https://github.com/glegrain)
// Riccardo Novaglia (https://github.com/richy24)
// Quentin Busuttil (https://github.com/Buzut)
// Lapsio (https://github.com/lapsio)
// ----------------------------------------------------------------------------------
// License: MIT
// ==================================================================================
// 7. Graphics (controller, display)

View File

@ -81,6 +81,7 @@
// --------------------------------
//
// version date comment
// 3.13.0 2016-11-23 added shell (determines standard shell)
// 3.12.0 2016-11-17 refactoring and extended currentLoad (better OSX coverage and added irq load)
// 3.11.2 2016-11-16 blockDevices: improved for older lsblk versions
// 3.11.1 2016-11-16 fixed small bug in blockDevices
@ -390,7 +391,7 @@ exports.system = system;
exports.time = osInfo.time;
exports.osInfo = osInfo.osInfo;
exports.versions = osInfo.versions;
exports.shell = osInfo.shell;
exports.cpu = cpu.cpu;
exports.cpuCurrentspeed = cpu.cpuCurrentspeed;

View File

@ -189,3 +189,26 @@ function versions(callback) {
}
exports.versions = versions;
function shell(callback) {
return new Promise((resolve, reject) => {
process.nextTick(() => {
if (_windows) {
let error = new Error(NOT_SUPPORTED);
if (callback) { callback(NOT_SUPPORTED) }
reject(error);
}
let result = '';
exec("echo $SHELL", function (error, stdout) {
if (!error) {
result = stdout.toString().split('\n')[0];
}
if (callback) { callback(result) }
resolve(result);
});
});
});
}
exports.shell = shell;