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.
37 lines
827 B
JavaScript
37 lines
827 B
JavaScript
5 years ago
|
"use strict";
|
||
|
|
||
|
const {createDataObject, LocalProperties, ID} = require("../../graphql/data-object");
|
||
|
const matchOrError = require("../../match-or-error");
|
||
|
|
||
|
module.exports = function (_types) {
|
||
|
return function BlockDevice({ name, path }) {
|
||
|
if (name != null) {
|
||
|
path = `/dev/${name}`;
|
||
|
} else if (path != null) {
|
||
|
let match = matchOrError(/^\/dev\/(.+)$/, path);
|
||
|
name = match[0];
|
||
|
}
|
||
|
|
||
|
/* FIXME: parent */
|
||
|
|
||
|
return createDataObject({
|
||
|
[LocalProperties]: {
|
||
|
path: path
|
||
|
},
|
||
|
lsblk: {
|
||
|
[ID]: name,
|
||
|
name: "name",
|
||
|
size: "size",
|
||
|
mountpoint: "mountpoint",
|
||
|
deviceNumber: "deviceNumber",
|
||
|
removable: "removable",
|
||
|
readOnly: "readOnly",
|
||
|
children: (device) => {
|
||
|
return device.children.map((child) => {
|
||
|
return BlockDevice({ name: child.name });
|
||
|
});
|
||
|
}
|
||
|
}
|
||
|
});
|
||
|
};
|
||
|
};
|