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 1.2.2 to 1.3.0

scripts/win_drives.vbs

41

build/linux.js

@@ -1,5 +0,7 @@

var childProcess, tableParser, _;
var async, childProcess, getMountPoint, tableParser, _;
childProcess = require('child_process');
async = require('async');
_ = require('lodash');

@@ -9,2 +11,14 @@

getMountPoint = function(device, callback) {
return childProcess.exec("grep \"^" + device + "\" /proc/mounts | cut -d ' ' -f 2", {}, function(error, stdout, stderr) {
if (error != null) {
return callback(error);
}
if (!_.isEmpty(stderr)) {
return callback(new Error(stderr));
}
return callback(null, stdout);
});
};
exports.list = function(callback) {

@@ -20,11 +34,18 @@ return childProcess.exec('lsblk -d --output NAME,MODEL,SIZE', {}, function(error, stdout, stderr) {

result = tableParser.parse(stdout);
result = _.map(result, function(row) {
var _ref;
return {
device: "/dev/" + (_.first(row.NAME)),
description: (_ref = row.MODEL) != null ? _ref.join(' ') : void 0,
size: _.first(row.SIZE).replace(/,/g, '.')
};
});
return callback(null, result);
return async.map(result, function(row, callback) {
var device;
device = "/dev/" + (_.first(row.NAME));
return getMountPoint(device, function(error, mountPoint) {
var _ref;
if (error != null) {
return callback(error);
}
return callback(null, {
device: device,
description: (_ref = row.MODEL) != null ? _ref.join(' ') : void 0,
size: _.first(row.SIZE).replace(/,/g, '.'),
mountpoint: mountPoint || void 0
});
});
}, callback);
});

@@ -31,0 +52,0 @@ };

@@ -1,5 +0,9 @@

var childProcess, tableParser, _;
var async, childProcess, getMountPoint, path, tableParser, _;
childProcess = require('child_process');
path = require('path');
async = require('async');
_ = require('lodash');

@@ -9,2 +13,20 @@

getMountPoint = function(device, callback) {
return childProcess.exec("diskutil info " + device, {}, function(error, stdout, stderr) {
var mount, mountPoint, result;
if (error != null) {
return callback(error);
}
if (!_.isEmpty(stderr)) {
return callback(new Error(stderr));
}
result = tableParser.parse(stdout);
mount = _.findWhere(result, {
Device: ['Mount']
});
mountPoint = (mount != null ? mount['Identifier:'][1] : void 0) || (mount != null ? mount[path.basename(device)][0] : void 0);
return callback(null, mountPoint);
});
};
exports.list = function(callback) {

@@ -29,14 +51,19 @@ return childProcess.exec('diskutil list', {}, function(error, stdout, stderr) {

});
result = _.map(result, function(row) {
return async.map(result, function(row, callback) {
var device, size, sizeMeasure;
device = row.pop();
device = "/dev/" + (row.pop());
sizeMeasure = row.pop();
size = row.pop();
return {
device: "/dev/" + device,
size: "" + size + " " + sizeMeasure,
description: row.join(' ')
};
});
return callback(null, result);
return getMountPoint(device, function(error, mountPoint) {
if (error != null) {
return callback(error);
}
return callback(null, {
device: device,
size: "" + size + " " + sizeMeasure,
description: row.join(' '),
mountpoint: mountPoint
});
});
}, callback);
});

@@ -46,19 +73,11 @@ };

exports.isSystem = function(drive, callback) {
return childProcess.exec("diskutil info " + drive.device, {}, function(error, stdout, stderr) {
var mountPoint, result, _ref;
return getMountPoint(drive.device, function(error, mountPoint) {
if (error != null) {
return callback(false);
}
if (!_.isEmpty(stderr)) {
return callback(false);
}
if (drive.device === '/dev/disk0') {
return callback(true);
}
result = tableParser.parse(stdout);
mountPoint = (_ref = _.findWhere(result, {
Device: ['Mount']
})) != null ? _ref['Identifier:'][1] : void 0;
return callback(mountPoint === '/');
});
};

@@ -1,2 +0,2 @@

var childProcess, tableParser, _;
var childProcess, path, _;

@@ -7,7 +7,9 @@ childProcess = require('child_process');

tableParser = require('table-parser');
path = require('path');
exports.list = function(callback) {
return childProcess.exec('wmic diskdrive get DeviceID, Caption, Size', {}, function(error, stdout, stderr) {
var result;
var script;
script = path.join(__dirname, '..', 'scripts', 'win_drives.vbs');
return childProcess.exec("cscript " + script + " //Nologo", {}, function(error, stdout, stderr) {
var output, result;
if (error != null) {

@@ -19,13 +21,15 @@ return callback(error);

}
result = tableParser.parse(stdout);
result = _.map(result, function(row) {
var size, _ref;
size = _.parseInt((_ref = row.Size) != null ? _ref[0] : void 0) / 1e+9 || void 0;
if (row.DeviceID.length > 1) {
row.Caption = row.Caption.concat(_.initial(row.DeviceID));
}
output = stdout.trim().replace(/\r/, '').split(/\n/g);
result = _.map(output, function(row) {
var driveInfo, size;
driveInfo = row.split('\t');
driveInfo = _.map(driveInfo, function(element) {
return element.trim();
});
size = _.parseInt(driveInfo[3]) / 1e+9 || void 0;
return {
device: _.last(row.DeviceID),
description: row.Caption.join(' '),
size: size != null ? "" + (Math.floor(size)) + " GB" : void 0
device: driveInfo[1],
description: driveInfo[0],
size: size != null ? "" + (Math.floor(size)) + " GB" : void 0,
mountpoint: driveInfo[2]
};

@@ -32,0 +36,0 @@ });

{
"name": "drivelist",
"version": "1.2.2",
"version": "1.3.0",
"description": "List all connected drives in your computer, in all major operating systems",

@@ -38,2 +38,3 @@ "main": "build/drivelist.js",

"dependencies": {
"async": "^1.4.0",
"lodash": "^3.0.1",

@@ -40,0 +41,0 @@ "table-parser": "0.0.3"

@@ -41,2 +41,3 @@ drivelist

size: '*750.2 GB'
mountpoint: '/'
},

@@ -61,2 +62,3 @@ {

size: '931.5G',
mountpoint: '/'
},

@@ -81,2 +83,3 @@ {

size: '1000 GB'
mountpoint: 'C:'
},

@@ -87,2 +90,3 @@ {

size: '15 GB'
mountpoint: 'D:'
}

@@ -155,2 +159,6 @@ ]

### v1.3.0
- Add `mountpoint` attribute to drives.
### v1.2.2

@@ -157,0 +165,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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