Giter Site home page Giter Site logo

diskinfo's Introduction

diskinfo

Disk usage info on both *nix (via df) and Windows (via WMIC) systems

npm z Build status

Install

npm install @dropb/diskinfo

Usage examples

// JS example (Windows)

const { diskinfo } = require('@dropb/diskinfo');

diskinfo()
  .then(result => console.log(result))
  .catch(err => console.error(err.message));
/* OUTPUT:
[{
    fstype: '3',
    size: 185429127168,
    used: 51971362816,
    avail: 133457764352,
    pcent: '29%',
    target: 'C:'
  },
  {
    fstype: '2',
    size: 16046358528,
    used: 4434288640,
    avail: 11612069888,
    pcent: '28%',
    target: 'F:'
  },
  {
    fstype: '4',
    size: 107569381376,
    used: 106081509376,
    avail: 1487872000,
    pcent: '99%',
    target: 'V:'
  }]
*/
// Typescript example (Ubuntu)

import { diskinfo, DiskInfo } from '@dropb/diskinfo';

async function run() {
  const result: DiskInfo = await diskinfo('./');
  console.log(result);
}
run();
/* OUTPUT:
{ fstype: '/dev/sda1',
  size: 47242534912,
  used: 21033943040,
  avail: 23785177088,
  pcent: '47%',
  target: '/' }
*/

API

/**
 * @param file - get info of the filesystem containing the specified file or directory
 * @returns promise for an object with the info for the specified file or directory
 */
function diskinfo(file: string): Promise<DiskInfo>;

/**
 * @returns promise for an array with the info for all mounted filesystem
 */
function diskinfo(): Promise<DiskInfo[]>;

/**
 * Info of the filesystem
 */
interface DiskInfo {
  /**
   * POSIX - File system type
   *
   * Win32 - Win32_LogicalDisk DriveType(as `String`!):
   * - "0": Unknown
   * - "1": No Root Directory
   * - "2": Removable Disk
   * - "3": Local Disk
   * - "4": Network Drive
   * - "5": Compact Disc
   * - "6": RAM Disk
   */
  fstype: string;
  /**
   * Total size in bytes
   */
  size: number;
  /**
   * Used size in bytes
   */
  used: number;
  /**
   * Available size in bytes
   */
  avail: number;
  /**
   * Percentage of used divided by size
   */
  pcent: string;
  /**
   * Mount point
   */
  target: string;
}

References

License

MIT

diskinfo's People

Contributors

curiositycigar avatar kukhariev avatar renovate-bot avatar renovate[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

curiositycigar

diskinfo's Issues

Action Required: Fix Renovate Configuration

There is an error with this repository's Renovate configuration that needs to be fixed. As a precaution, Renovate will stop PRs until it is resolved.

Error type: undefined. Note: this is a nested preset so please contact the preset author if you are unable to fix it yourself.

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Detected dependencies

github-actions
.github/workflows/nodejs.yml
  • actions/checkout v3
  • actions/setup-node v3
npm
package.json
  • @types/chai 4.3.3
  • @types/mocha 9.1.1
  • @types/node 10.17.60
  • chai 4.3.6
  • mocha 9.2.2
  • tslint 6.1.3
  • ts-node 10.9.1
  • typescript 4.4.3
  • node >= 10.10.0

  • Check this box to trigger a request for Renovate to run again on this repository

Bug with disk name

Hello. My USB disk has a name "DEEPIN 15_1". Your module detects only "DEEPIN". I guess it's a problem with parsing 'df' on linux. Fix please, I like your module, It really helps me.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.