Skip to content

sudhakar3697/node-detect-usb

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

Releases

No releases published

Sponsor this project

 

Packages

No packages published