mirror of
https://github.com/balena-io/balena-cli.git
synced 2025-04-27 22:40:06 +00:00
Merge pull request #1663 from balena-io/fix-local-flash
Fix `balena local flash`
This commit is contained in:
commit
731bd909d6
@ -22,7 +22,22 @@ import { getChalk, getVisuals } from '../../utils/lazy';
|
|||||||
async function getDrive(options: {
|
async function getDrive(options: {
|
||||||
drive?: string;
|
drive?: string;
|
||||||
}): Promise<SDK.sourceDestination.BlockDevice> {
|
}): Promise<SDK.sourceDestination.BlockDevice> {
|
||||||
return options.drive || getVisuals().drive('Select a drive');
|
const drive = options.drive || (await getVisuals().drive('Select a drive'));
|
||||||
|
|
||||||
|
const sdk = await import('etcher-sdk');
|
||||||
|
|
||||||
|
const adapter = new sdk.scanner.adapters.BlockDeviceAdapter(() => false);
|
||||||
|
const scanner = new sdk.scanner.Scanner([adapter]);
|
||||||
|
await scanner.start();
|
||||||
|
try {
|
||||||
|
const d = scanner.getBy('device', drive);
|
||||||
|
if (d === undefined || !(d instanceof sdk.sourceDestination.BlockDevice)) {
|
||||||
|
throw new Error(`Drive not found: ${options.drive}`);
|
||||||
|
}
|
||||||
|
return d;
|
||||||
|
} finally {
|
||||||
|
scanner.stop();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export const flash: CommandDefinition<
|
export const flash: CommandDefinition<
|
||||||
|
Loading…
x
Reference in New Issue
Block a user