fsSize() fixed parsing edge case issue mac OS
This commit is contained in:
parent
221792bc7c
commit
bbd1ce332d
@ -61,7 +61,7 @@ Lightweight collection of 50+ functions to retrieve detailed hardware, system an
|
||||
- simple to use
|
||||
- get detailed information about system, cpu, baseboard, battery, memory, disks/filesystem, network, docker, software, services and processes
|
||||
- supports Linux, macOS, partial Windows, FreeBSD, OpenBSD, NetBSD and SunOS support
|
||||
- no npm dependencies (for production)
|
||||
- no npm dependencies
|
||||
|
||||
**Attention**: this is a `node.js` library. It is supposed to be used as a backend/server-side library and will definitely not work within a browser.
|
||||
|
||||
@ -116,7 +116,7 @@ You can find all changes here: [detailed changelog][changelog-url]
|
||||
|
||||
[Node.js][nodejs-url] comes with some basic OS information, but I always wanted a little more. So I came up to write this little library. This library is still work in progress. It is supposed to be used as a backend/server-side library (will definitely not work within a browser). It requires node.js version 4.0 and above.
|
||||
|
||||
I was able to test it on several Debian, Raspbian, Ubuntu distributions as well as macOS (Mavericks, Yosemite, El Captain, Sierra, High Sierra, Mojave) and some Windows 7, Windows 10, FreeBSD, OpenBSD, NetBSD and SunOS machines. Not all functions are supported on all operating systems. Have a look at the function reference in the docs to get further details.
|
||||
I was able to test it on several Debian, Raspbian, Ubuntu distributions as well as macOS (Mavericks, Yosemite, El Captain, Sierra, High Sierra, Mojave, Catalina, Big Sur) and some Windows 7, Windows 8, Windows 10, FreeBSD, OpenBSD, NetBSD and SunOS machines. Not all functions are supported on all operating systems. Have a look at the function reference in the docs to get further details.
|
||||
|
||||
If you have comments, suggestions & reports, please feel free to contact me!
|
||||
|
||||
|
||||
@ -52,20 +52,20 @@
|
||||
<li>simple to use</li>
|
||||
<li>get detailed information about system, cpu, baseboard, battery, memory, disks/filesystem, network, docker, software, services and processes</li>
|
||||
<li>supports Linux, macOS, partial Windows, FreeBSD, OpenBSD, NetBSD and SunOS support</li>
|
||||
<li>no npm dependencies (for production)</li>
|
||||
<li>no npm dependencies</li>
|
||||
</ul>
|
||||
|
||||
<h2>Core Concept</h2>
|
||||
<p><a href="https://nodejs.org/en/" rel="nofollow">Node.js</a> comes with some basic OS information, but I always wanted a little more. So I came up to write this
|
||||
little library. This library is still work in progress. It requires node.js version 4.0 and above.</p>
|
||||
|
||||
<p>I was able to test it on several Debian, Raspbian, Ubuntu distributions as well as macOS (Mavericks, Yosemite, El Captain, Sierra, High Sierra, Mojave) and some Windows 7, Windows 10, FreeBSD, OpenBSD, NetBSD and SunOS machines.
|
||||
<p>I was able to test it on several Debian, Raspbian, Ubuntu distributions as well as macOS (Mavericks, Yosemite, El Captain, Sierra, High Sierra, Mojave, Catalina, Big Sur) and some Windows 7, Windows 8, Windows 10, FreeBSD, OpenBSD, NetBSD and SunOS machines.
|
||||
Not all functions are supported on all operating systems. Have a look at the function reference in the docs to get further details.</p>
|
||||
<p>If you have comments, suggestions & reports, please feel free to contact me on <a href="https://github.com/sebhildebrandt/systeminformation/issues">github</a>!</p>
|
||||
<p>I also created a nice little command line tool called <a href="https://github.com/sebhildebrandt/mmon" rel="nofollow">mmon</a> (micro-monitor) for Linux and macOS, also available via <a href="https://github.com/sebhildebrandt/mmon" rel="nofollow">github</a> and <a href="https://npmjs.org/package/mmon" rel="nofollow">npm</a></p>
|
||||
|
||||
<h4>Attention:</h4>
|
||||
<p>This library is supposed to be used as a <a href="https://nodejs.org/en/" rel="nofollow">node.js</a> backend/server-side library and will definilely not work within a browser.</p>
|
||||
<p>This library is supposed to be used as a <a href="https://nodejs.org/en/" rel="nofollow">node.js</a> backend/server-side library and will definitely not work within a browser.</p>
|
||||
|
||||
<h2>Installation</h2>
|
||||
<pre>$ npm install systeminformation --save</pre>
|
||||
@ -80,7 +80,7 @@ si.cpu()
|
||||
</code></pre>
|
||||
<h2>Callback, Promises, Async Await</h2>
|
||||
<p>Remember: all functions (except <span class="code">version</span> and <span class="code">time</span>) are implemented as asynchronous functions! There are now three ways to consume them:</p>
|
||||
<p><strong>Callback Style</strong></p>
|
||||
<p class="bold">Callback Style</p>
|
||||
<pre><code class="js">const si = require('systeminformation');
|
||||
|
||||
si.cpu(function(data) {
|
||||
@ -92,9 +92,7 @@ si.cpu(function(data) {
|
||||
console.log('- physical cores: ' + data.physicalCores);
|
||||
console.log('...');
|
||||
})</code></pre><br>
|
||||
<p><strong>Promise Style</strong></p>
|
||||
<p>Promises style is new since version 3.0.
|
||||
<p></p>
|
||||
<p class="bold">Promise Style</p>
|
||||
|
||||
<p>When omitting callback parameter (cb), then you can use all function in a promise oriented way. All functions (exept of <span class="code">version</span> and <span class="code">time</span>) are returning a promise, that you can consume:</p>
|
||||
<pre><code class="js">const si = require('systeminformation');
|
||||
@ -110,7 +108,7 @@ si.cpu()
|
||||
console.log('...');
|
||||
})
|
||||
.catch(error => console.error(error));</code></pre><br>
|
||||
<p><strong>Async/Await Style</strong></p>
|
||||
<p class="bold">Async/Await Style</p>
|
||||
<p>Since node v7.6 you can also use the async / await pattern. The above example would then look like this:</p>
|
||||
<pre><code class="js">const si = require('systeminformation');
|
||||
|
||||
@ -129,7 +127,7 @@ async function cpuData() {
|
||||
}
|
||||
}</code></pre><br>
|
||||
<h2>Issues</h2>
|
||||
<p>If you discover some empty or incorrect values, please be sure to first have a look at the <a href="issues.html">Known issues</a> section.</p>
|
||||
<p>If you discover some empty or incorrect values, please be sure to first have a look at the <a href="issues.html">Known Issues</a> section.</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -209,7 +209,7 @@
|
||||
<div class="title">Downloads last month</div>
|
||||
</div>
|
||||
<div class="col-xl-4 col-lg-4 col-md-4 col-12">
|
||||
<div class="numbers">377</div>
|
||||
<div class="numbers">380</div>
|
||||
<div class="title">Dependents</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -396,4 +396,4 @@
|
||||
</script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
</html>
|
||||
@ -59,7 +59,9 @@ function fsSize(callback) {
|
||||
const used = parseInt(((_linux || _freebsd || _openbsd || _netbsd) ? line[3] : line[2])) * 1024;
|
||||
const available = parseInt(((_linux || _freebsd || _openbsd || _netbsd) ? line[4] : line[3])) * 1024;
|
||||
const use = parseFloat((100.0 * (used / (used + available))).toFixed(2));
|
||||
const mount = line[line.length - 1];
|
||||
line.splice(0, (_linux || _freebsd || _openbsd || _netbsd) ? 6 : 5);
|
||||
const mount = line.join(' ');
|
||||
// const mount = line[line.length - 1];
|
||||
if (!data.find(el => (el.fs === fs && el.type === fsType))) {
|
||||
data.push({
|
||||
fs,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user