Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

drivelist

Package Overview
Dependencies
Maintainers
1
Versions
265
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

drivelist - npm Package Compare versions

Comparing version 9.0.2 to 9.1.0-apfs-is-virtual-19fca449f721d6dd09a957101e79940d8592233d

6

CHANGELOG.md

@@ -7,2 +7,8 @@ # Change Log

# v9.1.0
## (2020-08-06)
* Load bindings once [Alexis Svinartchouk]
* Mark APFS media as virtual and assign its mountpoints to the source drive [Alexis Svinartchouk]
# v9.0.2

@@ -9,0 +15,0 @@ ## (2020-05-29)

4

js/index.d.ts

@@ -29,7 +29,3 @@ export interface Mountpoint {

* @summary List available drives
* @function
* @public
*
* @returns {Promise} <Drive>[]
*
* @example

@@ -36,0 +32,0 @@ * const drivelist = require('drivelist');

@@ -25,9 +25,37 @@ "use strict";

const lsblk_1 = require("./lsblk");
const drivelistBindings = bindings('drivelist');
function bindingsList() {
return new Promise((resolve, reject) => {
drivelistBindings.list((error, drives) => {
if (error != null) {
reject(error);
}
else {
resolve(drives);
}
});
});
}
function handleApfs(disks) {
const apfs = [];
const other = [];
for (const disk of disks) {
if (disk.description === 'AppleAPFSMedia') {
apfs.push(disk);
}
else {
other.push(disk);
}
}
for (const disk of apfs) {
const source = other.find((d) => d.devicePath === disk.devicePath && !d.isVirtual);
if (source !== undefined) {
source.mountpoints.push(...disk.mountpoints);
disk.isVirtual = true;
}
}
}
/**
* @summary List available drives
* @function
* @public
*
* @returns {Promise} <Drive>[]
*
* @example

@@ -43,14 +71,10 @@ * const drivelist = require('drivelist');

const plat = os_1.platform();
if (plat === 'win32' || plat === 'darwin') {
return new Promise((resolve, reject) => {
bindings('drivelist').list((error, drives) => {
if (error != null) {
reject(error);
}
else {
resolve(drives);
}
});
});
if (plat === 'win32') {
return await bindingsList();
}
else if (plat === 'darwin') {
const disks = await bindingsList();
handleApfs(disks);
return disks;
}
else if (plat === 'linux') {

@@ -57,0 +81,0 @@ return await lsblk_1.lsblk();

@@ -54,9 +54,40 @@ /*

const drivelistBindings = bindings('drivelist');
function bindingsList(): Promise<Drive[]> {
return new Promise((resolve, reject) => {
drivelistBindings.list((error: Error, drives: Drive[]) => {
if (error != null) {
reject(error);
} else {
resolve(drives);
}
});
});
}
function handleApfs(disks: Drive[]): void {
const apfs: Drive[] = [];
const other: Drive[] = [];
for (const disk of disks) {
if (disk.description === 'AppleAPFSMedia') {
apfs.push(disk);
} else {
other.push(disk);
}
}
for (const disk of apfs) {
const source = other.find(
(d) => d.devicePath === disk.devicePath && !d.isVirtual,
);
if (source !== undefined) {
source.mountpoints.push(...disk.mountpoints);
disk.isVirtual = true;
}
}
}
/**
* @summary List available drives
* @function
* @public
*
* @returns {Promise} <Drive>[]
*
* @example

@@ -72,12 +103,8 @@ * const drivelist = require('drivelist');

const plat = platform();
if (plat === 'win32' || plat === 'darwin') {
return new Promise((resolve, reject) => {
bindings('drivelist').list((error: Error, drives: Drive[]) => {
if (error != null) {
reject(error);
} else {
resolve(drives);
}
});
});
if (plat === 'win32') {
return await bindingsList();
} else if (plat === 'darwin') {
const disks = await bindingsList();
handleApfs(disks);
return disks;
} else if (plat === 'linux') {

@@ -84,0 +111,0 @@ return await lsblk();

{
"name": "drivelist",
"version": "9.0.2",
"version": "9.1.0-apfs-is-virtual-19fca449f721d6dd09a957101e79940d8592233d",
"description": "List all connected drives in your computer, in all major operating systems",

@@ -5,0 +5,0 @@ "main": "js/index.js",

@@ -169,7 +169,5 @@ <!-- Make sure you edit doc/README.hbs rather than README.md because the latter is auto-generated -->

### drivelist~list() ⇒ <code>Promise</code>
### drivelist~list()
**Kind**: inner method of [<code>drivelist</code>](#module_drivelist)
**Summary**: List available drives
**Returns**: <code>Promise</code> - <Drive>[]
**Access**: public
**Example**

@@ -176,0 +174,0 @@ ```js

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc