@bleed-believer/mnt
TypeScript icon, indicating that this package has built-in type declarations

0.1.1 • Public • Published

@bleed-believer/mnt

Manage partitions in linux.

Disclaimer

Since ESM hs been heavely adopted by the whole node.js community (including transpilers, unit testing, and many other libraries), the CJS support has been removed. If you still needs the CJS compatibility, please use this version or earlier.

Installation

Simply use:

npm i --save @bleed-believer/mnt

Usage

  • Gets all mounted resources:

    import { Resource } from '@bleed-believer/mnt';
    
    const resources = await Resource.get();
    console.log(resources);
  • Gets an specific resource:

    import { Resource } from '@bleed-believer/mnt';
    
    const resource = await Resource.find(x => x.target === '/mnt/z');
    console.log(resource);
  • Checks if the resource is mounted:

    import { Resource } from '@bleed-believer/mnt';
    
    const resp = await Resource.some(x => x.target === '/mnt/z');
    console.log('exists???', resp);
  • Filtering some devices:

    import { Resource } from '@bleed-believer/mnt';
    
    const resources = await Resource.filter(x => x.fstype === 'ext4');
    console.log(resources);
  • Mounting a resource listed in /etc/fstab:

    import { Resource } from '@bleed-believer/mnt';
    
    const obj = await Resource.mount('/mnt/z');
    console.log(obj);
  • Mounting a new resource:

    import { Resource } from '@bleed-believer/mnt';
    
    const obj = await Resource.mount({
        fstype: 'ntfs',
        source: '/dev/sdb2',
        target: '/mnt/z'
    });
    console.log(obj);
  • Unmounting a resource:

    import { Resource } from '@bleed-believer/mnt';
    
    // Using only the target folder (listed in /etc/fstab)...
    await Resource.umount('/mnt/z');
    
    // ...or usinig an instance
    const obj = await Resource.find(x => x.target === '/mnt/z');
    await obj.umount();

Readme

Keywords

Package Sidebar

Install

npm i @bleed-believer/mnt

Weekly Downloads

19

Version

0.1.1

License

MIT

Unpacked Size

18.1 kB

Total Files

33

Last publish

Collaborators

  • sleep-written