drivelist
Advanced tools
Comparing version 1.1.2 to 1.2.0
@@ -1,2 +0,2 @@ | ||
var linux, os, osx, win32; | ||
var getOSModule, linux, os, osx, win32; | ||
@@ -11,16 +11,23 @@ os = require('os'); | ||
exports.list = function(callback) { | ||
var error, operatingSystem; | ||
getOSModule = function() { | ||
var operatingSystem; | ||
operatingSystem = os.platform(); | ||
switch (operatingSystem) { | ||
case 'darwin': | ||
return osx.list(callback); | ||
return osx; | ||
case 'win32': | ||
return win32.list(callback); | ||
return win32; | ||
case 'linux': | ||
return linux.list(callback); | ||
return linux; | ||
default: | ||
error = new Error("Your OS is not supported by this module: " + operatingSystem); | ||
return callback(error); | ||
throw new Error("Your OS is not supported by this module: " + operatingSystem); | ||
} | ||
}; | ||
exports.list = function(callback) { | ||
return getOSModule().list(callback); | ||
}; | ||
exports.isSystem = function(drive, callback) { | ||
return getOSModule().isSystem(drive, callback); | ||
}; |
@@ -30,1 +30,15 @@ var childProcess, tableParser, _; | ||
}; | ||
exports.isSystem = function(drive, callback) { | ||
return childProcess.exec("lsblk " + drive.device + " -d", {}, function(error, stdout, stderr) { | ||
var result, _ref; | ||
if (error != null) { | ||
return callback(false); | ||
} | ||
if (!_.isEmpty(stderr)) { | ||
return callback(false); | ||
} | ||
result = tableParser.parse(stdout); | ||
return callback(((_ref = result[0].RM) != null ? _ref[0] : void 0) !== '1'); | ||
}); | ||
}; |
@@ -42,1 +42,21 @@ var childProcess, tableParser, _; | ||
}; | ||
exports.isSystem = function(drive, callback) { | ||
return childProcess.exec("diskutil info " + drive.device, {}, function(error, stdout, stderr) { | ||
var mountPoint, result, _ref; | ||
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 === '/'); | ||
}); | ||
}; |
@@ -31,1 +31,5 @@ var childProcess, tableParser, _; | ||
}; | ||
exports.isSystem = function(drive, callback) { | ||
return callback(drive.device.toUpperCase() === '\\\\.\\PHYSICALDRIVE0'); | ||
}; |
{ | ||
"name": "drivelist", | ||
"version": "1.1.2", | ||
"description": "List all connected drives in your computer, in all major operating systems", | ||
"version": "1.2.0", | ||
"description": "List all connected drives in your computer, in all major operating systems", | ||
"main": "build/drivelist.js", | ||
@@ -6,0 +6,0 @@ "homepage": "https://github.com/resin-io/drivelist", |
@@ -110,2 +110,11 @@ drivelist | ||
Predicates | ||
---------- | ||
### drivelist.isSystem(drive, callback) | ||
Determines if a drive returned by `drivelist.list()` is a system drive. | ||
The callbacks gets passed a single boolean value. | ||
Tests | ||
@@ -142,2 +151,6 @@ ----- | ||
### v1.2.0 | ||
- Implement isSystem predicate. | ||
### v1.1.2 | ||
@@ -144,0 +157,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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
36726
11246
275
170