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.

25 lines
553 B
JavaScript

"use strict";
const Promise = require("bluebird");
const memoizee = require("memoizee");
const smartctl = require("../../../wrappers/smartctl");
const All = require("../../../graphql/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);
}
});
});
};
};