balena-cli
Version:
The official balena Command Line Interface
39 lines (38 loc) • 1.55 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
const core_1 = require("@oclif/core");
const lazy_1 = require("../../utils/lazy");
class UtilAvailableDrivesCmd extends core_1.Command {
async run() {
await this.parse(UtilAvailableDrivesCmd);
const sdk = await Promise.resolve().then(() => require('etcher-sdk'));
const adapter = new sdk.scanner.adapters.BlockDeviceAdapter({
includeSystemDrives: () => false,
});
const scanner = new sdk.scanner.Scanner([adapter]);
await scanner.start();
function prepareDriveInfo(drive) {
const size = drive.size / 1000000000;
return {
device: drive.device,
size: `${size.toFixed(1)} GB`,
description: drive.description,
};
}
if (scanner.drives.size === 0) {
console.error(`${(0, lazy_1.getChalk)().red('x')} No available drives were detected, plug one in!`);
}
else {
console.log((0, lazy_1.getVisuals)().table.horizontal(Array.from(scanner.drives).map(prepareDriveInfo), ['device', 'size', 'description']));
}
scanner.stop();
}
}
UtilAvailableDrivesCmd.description = (0, lazy_1.stripIndent) `
List available drives.
List available drives which are usable for writing an OS image to.
Does not list system drives.
`;
UtilAvailableDrivesCmd.offlineCompatible = true;
exports.default = UtilAvailableDrivesCmd;
//# sourceMappingURL=available-drives.js.map
;