From 1ae4ef8c088c5b7ab60b91182a832682172234b2 Mon Sep 17 00:00:00 2001 From: Sebastian Hildebrandt Date: Wed, 23 Nov 2016 10:31:03 +0100 Subject: [PATCH] added shell (returns standard shell) --- CHANGELOG.md | 2 ++ README.md | 2 ++ lib/graphics.js | 5 ----- lib/index.js | 3 ++- lib/osinfo.js | 23 +++++++++++++++++++++++ 5 files changed, 29 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1237b40..f84409e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 | diff --git a/README.md b/README.md index 44e280e..a6ae04c 100644 --- a/README.md +++ b/README.md @@ -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' | diff --git a/lib/graphics.js b/lib/graphics.js index 61c4b82..cef03da 100644 --- a/lib/graphics.js +++ b/lib/graphics.js @@ -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) diff --git a/lib/index.js b/lib/index.js index cf9d329..a71dd1a 100644 --- a/lib/index.js +++ b/lib/index.js @@ -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; diff --git a/lib/osinfo.js b/lib/osinfo.js index 6dfdfde..1d64a34 100644 --- a/lib/osinfo.js +++ b/lib/osinfo.js @@ -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;