Skip to content

fishylunar/disklist

Repository files navigation

disklist

JavaScript / TypeScript Library for getting info about drives & disks.

CodeFactor Quality Gate Status Bugs Code Smells Duplicated Lines (%) Lines of Code Reliability Rating Maintainability Rating Technical Debt Vulnerabilities Security Rating

SonarCloud

Deno JS TypeScript

Windows macOS Linux

Example:

import Disklist from "disklist";

const disks = Disklist.listDrivesSync();
console.log(disks.filter((disk) => disk.removable));

Would when run on a Windows machine result in: (With a USB Drive plugged in)

[
  {
    device: "\\\\.\\PHYSICALDRIVE1",
    displayName: "WINDOWS10",
    description: "USB Mass Storage Device",
    size: 31264289280,
    mountpoints: [{ path: "E:/" }],
    raw: "\\\\.\\PHYSICALDRIVE1",
    protected: false,
    system: false,
    removable: true,
    fileSystem: "FAT32",
    driveType: "USB Drive",
    mounted: true,
    serialNumber: "2a30d57d2e49d654229299c66f80e0e4",
  },
];

And on MacOS (with the same drive plugged in) it would result in:

[
  {
    device: "/dev/disk8",
    displayName: "WINDOWS10",
    description: "USB Mass Storage Device",
    size: 31266439168,
    mountpoints: [],
    raw: "/dev/disk8",
    protected: false,
    system: false,
    removable: true,
    fileSystem: "FAT32",
    driveType: "USB Drive",
    mounted: false,
    serialNumber: "2a30d57d2e49d654229299c66f80e0e4",
  },
];