Skip to content

Commit 8142447

Browse files
authored
Merge pull request #2066 from onflow/cf/fix-exit
Fix: respect termination in `flow init` prompt
2 parents 1ad0d69 + 2fdda08 commit 8142447

3 files changed

Lines changed: 16 additions & 5 deletions

File tree

internal/dependencymanager/dependencyinstaller.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -492,7 +492,11 @@ func (di *DependencyInstaller) handleFoundContract(networkName, contractAddr, co
492492
// If no hash, ignore
493493
if dependency != nil && dependency.Hash != "" && dependency.Hash != originalContractDataHash {
494494
msg := fmt.Sprintf("The latest version of %s is different from the one you have locally. Do you want to update it?", contractName)
495-
if !prompt.GenericBoolPrompt(msg) {
495+
shouldUpdate, err := prompt.GenericBoolPrompt(msg)
496+
if err != nil {
497+
return err
498+
}
499+
if !shouldUpdate {
496500
return nil
497501
}
498502
}

internal/prompt/prompt.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -674,10 +674,13 @@ func InstallPathPrompt(defaultPath string) string {
674674
return filepath.Clean(install)
675675
}
676676

677-
func GenericBoolPrompt(msg string) bool {
678-
result, _ := RunSingleSelect([]string{"Yes", "No"}, msg)
677+
func GenericBoolPrompt(msg string) (bool, error) {
678+
result, err := RunSingleSelect([]string{"Yes", "No"}, msg)
679+
if err != nil {
680+
return false, err
681+
}
679682

680-
return result == "Yes"
683+
return result == "Yes", nil
681684
}
682685

683686
func GenericSelect(items []string, message string) string {

internal/super/init.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,11 @@ func startInteractiveInit(
258258
}
259259

260260
msg := "Would you like to install any standard Flow contracts and their dependencies?"
261-
if prompt.GenericBoolPrompt(msg) {
261+
installContracts, err := prompt.GenericBoolPrompt(msg)
262+
if err != nil {
263+
return "", err
264+
}
265+
if installContracts {
262266
err := dependencymanager.PromptInstallCoreContracts(logger, state, tempDir, nil)
263267
if err != nil {
264268
return "", err

0 commit comments

Comments
 (0)