detect-usb
v3.0.0
Published
Detect USB and get mount points/paths
Downloads
31
Maintainers
Readme
detect-usb
Detect USB and get mount points/paths
Usage
const usbEvents = require('detect-usb');
// To start listening
usbEvents.startListening();
// To get list of connected USBs
(async () => {
console.log(await usbEvents.getUSBList());
})();
usbEvents.on('insert', (data) => {
console.log(data);
})
usbEvents.on('eject', (data) => {
console.log(data);
})
// To stop listening
usbEvents.stopListening();
Sample Data
{
event: 'insert',
data:
{
key: '/media/test/sss',
name: 'sss',
devicepath: '/dev/sda',
isAccessible: true
}
}
{ event: 'eject', data: { key: '/media/test/sss' } }
Note
- Verified on Windows & Linux
- Uses usb-detection & drivelist