Skip to content

Latest commit

 

History

History
49 lines (37 loc) · 848 Bytes

README.md

File metadata and controls

49 lines (37 loc) · 848 Bytes

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