Giter VIP home page Giter VIP logo

drivelist's Introduction

drivelist

npm version dependencies Build Status Build status

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

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

Supports:

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

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

var drivelist = require('drivelist');

drivelist.list(function(error, disks) {
		if (error) throw error;
		console.log(disks);
});

Mac OS X:

[
	{
		device: '/dev/disk0',
		description: 'GUID_partition_scheme',
		size: '*750.2 GB'
		mountpoint: '/'
	},
	{
		device: '/dev/disk1',
		description: 'Apple_HFS Macintosh HD',
		size: '*748.9 GB'
	}
]

GNU/Linux

[
	{
		device: '/dev/sda',
		description: 'WDC WD10JPVX-75J',
		size: '931.5G',
		mountpoint: '/'
	},
	{
		device: '/dev/sr0',
		description: 'DVD+-RW GU90N',
		size: '1024M'
	}
]

Windows

[
	{
		device: '\\\\.\\PHYSICALDRIVE0',
		description: 'WDC WD10JPVX-75JC3T0',
		size: '1000 GB'
		mountpoint: 'C:'
	},
	{
		device: '\\\\.\\PHYSICALDRIVE1',
		description: 'Generic STORAGE DEVICE USB Device',
		size: '15 GB'
		mountpoint: 'D:'
	}
]

Installation

Install drivelist by running:

$ npm install --save drivelist

Documentation

drivelist.list(callback)

List available drives.

The function will throw an error if you attempt to call it from an unsupported operating system.

callback(error, drives)

  • error is a possible error.
  • drives is an array of objects describing the drives found.

Predicates

drivelist.isSystem(drive, callback)

Determines if a drive returned by drivelist.list() is a system drive.

The callbacks gets passed a single boolean value.

Tests

Run the test suite by doing:

$ gulp 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 coffeelint runs without any warning:

$ gulp lint

Support

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

ChangeLog

v1.3.0

  • Add mountpoint attribute to drives.

v1.2.2

  • Fix issue where a removable drive was detected as a system drive in Linux.

v1.2.1

Fix win32 issue where DeviceID gets part of the device description.

v1.2.0

  • Implement isSystem predicate.

v1.1.2

  • Prevent empty lsblk model crash the module. Return undefined description instead.

v1.1.1

  • Prevent empty wmic size crash the module. Return undefined size instead.

v1.1.0

  • Return non supported OS error to the callback instead of just throwing it.

License

The project is licensed under the MIT license.

drivelist's People

Contributors

jviotti avatar

Watchers

 avatar  avatar

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.