You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
26 lines
578 B
JavaScript
26 lines
578 B
JavaScript
"use strict";
|
|
|
|
const Promise = require("bluebird");
|
|
const memoizee = require("memoizee");
|
|
|
|
const smartctl = require("../../../packages/exec-smartctl");
|
|
const All = require("../../../packages/graphql-interface/symbols/all");
|
|
|
|
module.exports = function () {
|
|
let scanOnce = memoizee(smartctl.scan);
|
|
|
|
return function (paths) {
|
|
return Promise.try(() => {
|
|
return scanOnce();
|
|
}).then((devices) => {
|
|
return paths.map((path) => {
|
|
if (path === All) {
|
|
return devices;
|
|
} else {
|
|
return devices.find((device) => device.path === path);
|
|
}
|
|
});
|
|
});
|
|
};
|
|
};
|