mirror of
https://github.com/balena-io/balena-cli.git
synced 2025-01-30 08:03:55 +00:00
Lazy-load etcher-sdk to speed up startup
Change-type: patch
This commit is contained in:
parent
f780d47198
commit
3cc632fbbb
@ -1,12 +1,12 @@
|
||||
import chalk from 'chalk';
|
||||
import * as sdk from 'etcher-sdk';
|
||||
import * as _sdk from 'etcher-sdk';
|
||||
|
||||
import { CustomDynamicList } from './custom-dynamic-list';
|
||||
|
||||
export class DriveList extends CustomDynamicList<
|
||||
sdk.sourceDestination.BlockDevice
|
||||
_sdk.sourceDestination.BlockDevice
|
||||
> {
|
||||
constructor(private scanner: sdk.scanner.Scanner) {
|
||||
constructor(private scanner: _sdk.scanner.Scanner) {
|
||||
super(
|
||||
'Select a drive',
|
||||
`${chalk.red('x')} No available drives were detected, plug one in!`,
|
||||
@ -17,6 +17,7 @@ export class DriveList extends CustomDynamicList<
|
||||
}
|
||||
|
||||
protected *getThings() {
|
||||
const sdk: typeof _sdk = require('etcher-sdk')
|
||||
for (const drive of this.scanner.drives) {
|
||||
if (drive instanceof sdk.sourceDestination.BlockDevice) {
|
||||
yield drive;
|
||||
@ -24,7 +25,7 @@ export class DriveList extends CustomDynamicList<
|
||||
}
|
||||
}
|
||||
|
||||
protected format(drive: sdk.sourceDestination.BlockDevice) {
|
||||
protected format(drive: _sdk.sourceDestination.BlockDevice) {
|
||||
const size = drive.size / 1e9;
|
||||
return `${drive.device} (${size.toFixed(1)} GB) - ${drive.description}`;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user