From 3cc632fbbbf7185755080e0c7d0099077311d118 Mon Sep 17 00:00:00 2001 From: Pagan Gazzard Date: Fri, 11 Jan 2019 18:29:58 +0000 Subject: [PATCH] Lazy-load etcher-sdk to speed up startup Change-type: patch --- lib/utils/visuals/drive-list.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/utils/visuals/drive-list.ts b/lib/utils/visuals/drive-list.ts index ac76d6cb..b63341f7 100644 --- a/lib/utils/visuals/drive-list.ts +++ b/lib/utils/visuals/drive-list.ts @@ -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}`; }