List all connected drives in your computer, in all major operating systems
Branch: master
Clone or download
Latest commit 57e5606 Feb 20, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
ci fix(ci): Only prebuild with Node 10 May 9, 2018
doc Remove outdated docs. Jan 28, 2019
example refactor(windows): reimplement in C++ (#178) Jun 26, 2017
lib Fix parsing lsblk --pairs output for disks with no partition table Feb 20, 2019
src feat(mac): Native implementation for drivelist Jan 28, 2019
tests
.editorconfig test(diskutil): Add tests for devices without partitions Mar 15, 2018
.eslintrc.yml feat(lib): Use diskutil directly, parse plist output Mar 8, 2018
.gitignore feat(package): Add prebuilds for native bindings Sep 28, 2017
.npmignore chore(ci): Add CI deployment scripts Oct 13, 2017
.resinci.yml ci: Add .resinci.yml Aug 3, 2018
.travis.yml
CHANGELOG.md v7.0.3 Feb 20, 2019
LICENSE Transform repository to follow Etcher-umbrella project style Oct 31, 2016
README.md Remove outdated docs. Jan 28, 2019
appveyor.yml fix(ci): Added x86 builds to AppVeyor Aug 7, 2018
binding.gyp feat(mac): Native implementation for drivelist Jan 28, 2019
package.json v7.0.3 Feb 20, 2019
requirements.txt fix(test): Add python requirements.txt for tests Jul 2, 2018

README.md

drivelist

List all connected drives in your computer, in all major operating systems.

Current Release License Downloads Travis CI status AppVeyor status Dependency status Gitter Chat

Notice that this module does not require admin privileges to get the drives in any supported operating system.

Supports:

  • Windows.
  • GNU/Linux distributions that include util-linux and udev.
  • Mac OS X.

When the user executes drivelist.list(), the module checks the operating system of the client and executes the corresponding drive scanning script.

Examples (the output will vary depending on your machine):

const drivelist = require('drivelist');

drivelist.list((error, drives) => {
  if (error) {
    throw error;
  }

  console.log(drives);
});

Mac OS X:

[
  {
    device: '/dev/disk0',
    displayName: '/dev/disk0',
    description: 'GUID_partition_scheme',
    size: 68719476736,
    mountpoints: [
      {
        path: '/'
      }
    ],
    raw: '/dev/rdisk0',
    protected: false,
    system: true
  },
  {
    device: '/dev/disk1',
    displayName: '/dev/disk1',
    description: 'Apple_HFS Macintosh HD',
    size: 68719476736,
    mountpoints: [],
    raw: '/dev/rdisk0',
    protected: false,
    system: true
  }
]

GNU/Linux

[
  {
    device: '/dev/sda',
    displayName: '/dev/sda',
    description: 'WDC WD10JPVX-75J',
    size: 68719476736,
    mountpoints: [
      {
        path: '/'
      }
    ],
    raw: '/dev/sda',
    protected: false,
    system: true
  },
  {
    device: '/dev/sdb',
    displayName: '/dev/sdb',
    description: 'DataTraveler 2.0',
    size: 7823458304,
    mountpoints: [
      {
        path: '/media/UNTITLED'
      }
    ],
    raw: '/dev/sdb',
    protected: true,
    system: false
  }
]

Windows

[
  {
    device: '\\\\.\\PHYSICALDRIVE0',
    displayName: 'C:',
    description: 'WDC WD10JPVX-75JC3T0',
    size: 68719476736,
    mountpoints: [
      {
        path: 'C:'
      }
    ],
    raw: '\\\\.\\PHYSICALDRIVE0',
    protected: false,
    system: true
  },
  {
    device: '\\\\.\\PHYSICALDRIVE1',
    displayName: 'D:, F:',
    description: 'Generic STORAGE DEVICE USB Device',
    size: 7823458304,
    mountpoints: [
      {
        path: 'D:'
      },
      {
        path: 'F:'
      }
    ],
    raw: '\\\\.\\PHYSICALDRIVE1',
    protected: true,
    system: false
  },
  {
    device: '\\\\.\\PHYSICALDRIVE2',
    displayName: '\\\\.\\PHYSICALDRIVE2',
    description: 'Silicon-Power2G',
    size: 2014314496,
    mountpoints: [],
    raw: '\\\\.\\PHYSICALDRIVE2',
    protected: false,
    system: false
  }
]

Installation

Install drivelist by running:

$ npm install --save drivelist

Documentation

drivelist.list(callback) ⇒ Undefined

Kind: static method of drivelist
Summary: List available drives
Access: public

Param Type Description
callback function callback (error, drives)

Example

const drivelist = require('drivelist');

drivelist.list((error, drives) => {
  if (error) {
    throw error;
  }

  drives.forEach((drive) => {
    console.log(drive);
  });
});

Tests

Run the test suite by doing:

$ npm test

Contribute

We're looking forward to support more operating systems. Please raise an issue or even better, send a PR to increase support!

Before submitting a PR, please make sure that you include tests, and that the linter runs without any warning:

$ npm run lint

Support

If you're having any problem, please raise an issue on GitHub.

License

The project is licensed under the Apache 2.0 license.