systeminformation 5.15.1 → 5.16.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -24,8 +24,6 @@
24
24
  [![Git Issues][issues-img]][issues-url]
25
25
  [![Closed Issues][closed-issues-img]][closed-issues-url]
26
26
  <img src="docs/assets/no-dependencies.svg" alt="no dependencies">
27
- [![Code Quality: Javascript][lgtm-badge]][lgtm-badge-url]
28
- [![Total alerts][lgtm-alerts]][lgtm-alerts-url]
29
27
  [![Caretaker][caretaker-image]][caretaker-url]
30
28
  [![Sponsoring][sponsor-badge]][sponsor-url]
31
29
  [![MIT license][license-img]][license-url]
@@ -112,6 +110,8 @@ si.cpu()
112
110
 
113
111
  (last 7 major and minor version releases)
114
112
 
113
+ - Version 5.16.0: `fsSize()` added rw property
114
+ - Version 5.15.0: `blockDevices()` added device
115
115
  - Version 5.14.0: `blockDevices()` added raid group member (linux)
116
116
  - Version 5.13.0: `networkConnections()` added process name (mac OS)
117
117
  - Version 5.12.0: `cpu()` added performance and efficiency cores
@@ -489,6 +489,7 @@ Full function reference with examples can be found at [https://systeminformation
489
489
  | | [0].available | X | X | X | X | | used in bytes |
490
490
  | | [0].use | X | X | X | X | | used in % |
491
491
  | | [0].mount | X | X | X | X | | mount point |
492
+ | | [0].rw | X | X | X | X | | read and write (false if read only) |
492
493
  | si.fsOpenFiles(cb) | {...} | X | X | X | | | count max/allocated file descriptors |
493
494
  | | max | X | X | X | | | max file descriptors |
494
495
  | | allocated | X | X | X | | | current open files count |
@@ -1056,11 +1057,6 @@ All other trademarks are the property of their respective owners.
1056
1057
  [downloads-image]: https://img.shields.io/npm/dm/systeminformation.svg?style=flat-square
1057
1058
  [downloads-url]: https://npmjs.org/package/systeminformation
1058
1059
 
1059
- [lgtm-badge]: https://img.shields.io/lgtm/grade/javascript/g/sebhildebrandt/systeminformation.svg?style=flat-square
1060
- [lgtm-badge-url]: https://lgtm.com/projects/g/sebhildebrandt/systeminformation/context:javascript
1061
- [lgtm-alerts]: https://img.shields.io/lgtm/alerts/g/sebhildebrandt/systeminformation.svg?style=flat-square
1062
- [lgtm-alerts-url]: https://lgtm.com/projects/g/sebhildebrandt/systeminformation/alerts
1063
-
1064
1060
  [sponsor-badge]: https://img.shields.io/badge/-Buy%20me%20a%20coffee-blue?style=flat-square
1065
1061
  [sponsor-url]: https://www.buymeacoffee.com/systeminfo
1066
1062
 
package/lib/filesystem.js CHANGED
@@ -39,6 +39,7 @@ let _disk_io = {};
39
39
  function fsSize(callback) {
40
40
 
41
41
  let macOsDisks = [];
42
+ let osMounts = [];
42
43
 
43
44
  function getmacOsFsType(fs) {
44
45
  if (!fs.startsWith('/')) { return 'NFS'; }
@@ -86,6 +87,7 @@ function fsSize(callback) {
86
87
  const used = parseInt(((_linux || _freebsd || _openbsd || _netbsd) ? line[3] : line[2])) * 1024;
87
88
  const available = parseInt(((_linux || _freebsd || _openbsd || _netbsd) ? line[4] : line[3])) * 1024;
88
89
  const use = parseFloat((100.0 * (used / (used + available))).toFixed(2));
90
+ let rw = osMounts && Object.keys(osMounts).length > 0 ? osMounts[fs] || false : null;
89
91
  line.splice(0, (_linux || _freebsd || _openbsd || _netbsd) ? 6 : 5);
90
92
  const mount = line.join(' ');
91
93
  if (!data.find(el => (el.fs === fs && el.type === fsType))) {
@@ -96,7 +98,8 @@ function fsSize(callback) {
96
98
  used,
97
99
  available,
98
100
  use,
99
- mount
101
+ mount,
102
+ rw
100
103
  });
101
104
  }
102
105
  }
@@ -110,18 +113,37 @@ function fsSize(callback) {
110
113
  let data = [];
111
114
  if (_linux || _freebsd || _openbsd || _netbsd || _darwin) {
112
115
  let cmd = '';
116
+ macOsDisks = [];
117
+ osMounts = {};
113
118
  if (_darwin) {
114
119
  cmd = 'df -kP';
115
120
  try {
116
121
  macOsDisks = execSync('diskutil list').toString().split('\n').filter(line => {
117
122
  return !line.startsWith('/') && line.indexOf(':') > 0;
118
123
  });
124
+ execSync('mount').toString().split('\n').filter(line => {
125
+ return line.startsWith('/');
126
+ }).forEach((line) => {
127
+ osMounts[line.split(' ')[0]] = line.toLowerCase().indexOf('read-only') === -1;
128
+ });
119
129
  } catch (e) {
120
- macOsDisks = [];
130
+ util.noop();
121
131
  }
122
132
  }
123
- if (_linux) { cmd = 'df -lkPTx squashfs'; }
124
- if (_freebsd || _openbsd || _netbsd) { cmd = 'df -lkPT'; }
133
+ if (_linux) {
134
+ cmd = 'df -lkPTx squashfs';
135
+ execSync('cat /proc/mounts 2>/dev/null').toString().split('\n').filter(line => {
136
+ return line.startsWith('/');
137
+ }).forEach((line) => {
138
+ osMounts[line.split(' ')[0]] = line.toLowerCase().indexOf('rw') >= 0;
139
+ });
140
+ }
141
+ if (_freebsd || _openbsd || _netbsd) {
142
+ cmd = 'df -lkPT';
143
+ execSync('mount').toString().split('\n').forEach((line) => {
144
+ osMounts[line.split(' ')[0]] = line.toLowerCase().indexOf('read-only') === -1;
145
+ });
146
+ }
125
147
  exec(cmd, { maxBuffer: 1024 * 1024 }, function (error, stdout) {
126
148
  let lines = filterLines(stdout);
127
149
  data = parseDf(lines);
@@ -151,7 +173,7 @@ function fsSize(callback) {
151
173
  if (_windows) {
152
174
  try {
153
175
  // util.wmic('logicaldisk get Caption,FileSystem,FreeSpace,Size').then((stdout) => {
154
- util.powerShell('Get-CimInstance Win32_logicaldisk | select Caption,FileSystem,FreeSpace,Size | fl').then((stdout, error) => {
176
+ util.powerShell('Get-CimInstance Win32_logicaldisk | select Access,Caption,FileSystem,FreeSpace,Size | fl').then((stdout, error) => {
155
177
  if (!error) {
156
178
  let devices = stdout.toString().split(/\n\s*\n/);
157
179
  devices.forEach(function (device) {
@@ -159,6 +181,8 @@ function fsSize(callback) {
159
181
  const size = util.toInt(util.getValue(lines, 'size', ':'));
160
182
  const free = util.toInt(util.getValue(lines, 'freespace', ':'));
161
183
  const caption = util.getValue(lines, 'caption', ':');
184
+ const rwValue = util.getValue(lines, 'access', ':');
185
+ const rw = rwValue ? (util.toInt(rwValue) !== 1) : null;
162
186
  if (size) {
163
187
  data.push({
164
188
  fs: caption,
@@ -167,7 +191,8 @@ function fsSize(callback) {
167
191
  used: size - free,
168
192
  available: free,
169
193
  use: parseFloat(((100.0 * (size - free)) / size).toFixed(2)),
170
- mount: caption
194
+ mount: caption,
195
+ rw
171
196
  });
172
197
  }
173
198
  });
package/lib/index.d.ts CHANGED
@@ -434,6 +434,7 @@ export namespace Systeminformation {
434
434
  available: number;
435
435
  use: number;
436
436
  mount: string;
437
+ rw: boolean | null;
437
438
  }
438
439
 
439
440
  interface FsOpenFilesData {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "systeminformation",
3
- "version": "5.15.1",
3
+ "version": "5.16.1",
4
4
  "description": "Advanced, lightweight system and OS information library",
5
5
  "license": "MIT",
6
6
  "author": "Sebastian Hildebrandt <hildebrandt@plus-innovations.com> (https://plus-innovations.com)",