-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add default flow for the
install
subcommand (#67)
- Loading branch information
1 parent
e84c677
commit 1c5410e
Showing
3 changed files
with
61 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,45 @@ | ||
import inquirer from 'inquirer'; | ||
|
||
import Logger from '../../../../logger'; | ||
import {Options, Platform} from '../../interfaces'; | ||
import {verifyOptions} from '../common'; | ||
import {installApp} from './app'; | ||
import {createAvd} from './avd'; | ||
|
||
export async function install(options: Options, sdkRoot: string, platform: Platform): Promise<boolean> { | ||
if (options.app) { | ||
const optionsVerified = verifyOptions('install', options); | ||
if (!optionsVerified) { | ||
return false; | ||
} | ||
|
||
let subcommandFlag = optionsVerified.subcommandFlag; | ||
if (subcommandFlag === '') { | ||
subcommandFlag = await promptForFlag(); | ||
} | ||
|
||
if (subcommandFlag === 'app') { | ||
return await installApp(options, sdkRoot, platform); | ||
} else if (options.avd) { | ||
} else if (subcommandFlag === 'avd') { | ||
return await createAvd(sdkRoot, platform); | ||
} | ||
|
||
return false; | ||
} | ||
|
||
async function promptForFlag(): Promise<string> { | ||
const flagAnswer = await inquirer.prompt({ | ||
type: 'list', | ||
name: 'flag', | ||
message: 'Select what do you want to install:', | ||
choices: ['APK', 'AVD'] | ||
}); | ||
Logger.log(); | ||
|
||
const flag = flagAnswer.flag; | ||
if (flag === 'APK') { | ||
return 'app'; | ||
} | ||
|
||
return 'avd'; | ||
} | ||
|