mirror of
https://github.com/balena-io/balena-cli.git
synced 2025-01-29 15:44:26 +00:00
Fix balena local flash
Change-type: patch
This commit is contained in:
parent
122b5a0655
commit
2860535c45
@ -22,7 +22,22 @@ import { getChalk, getVisuals } from '../../utils/lazy';
|
||||
async function getDrive(options: {
|
||||
drive?: string;
|
||||
}): 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<
|
||||
|
Loading…
x
Reference in New Issue
Block a user