mirror of
https://github.com/OffchainLabs/prysm.git
synced 2026-01-09 21:38:05 -05:00
Move Shared Packages into Math/ and IO/ (#9622)
* amend * building * build * userprompt * imports * build val * gaz * io file Co-authored-by: prylabs-bulldozer[bot] <58059840+prylabs-bulldozer[bot]@users.noreply.github.com>
This commit is contained in:
@@ -6,9 +6,9 @@ go_library(
|
||||
importpath = "github.com/prysmaticlabs/prysm/runtime/tos",
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
"//io/file:go_default_library",
|
||||
"//io/prompt:go_default_library",
|
||||
"//shared/cmd:go_default_library",
|
||||
"//shared/fileutil:go_default_library",
|
||||
"//shared/promptutil:go_default_library",
|
||||
"@com_github_logrusorgru_aurora//:go_default_library",
|
||||
"@com_github_sirupsen_logrus//:go_default_library",
|
||||
"@com_github_urfave_cli_v2//:go_default_library",
|
||||
|
||||
@@ -6,9 +6,9 @@ import (
|
||||
"strings"
|
||||
|
||||
"github.com/logrusorgru/aurora"
|
||||
"github.com/prysmaticlabs/prysm/io/file"
|
||||
"github.com/prysmaticlabs/prysm/io/prompt"
|
||||
"github.com/prysmaticlabs/prysm/shared/cmd"
|
||||
"github.com/prysmaticlabs/prysm/shared/fileutil"
|
||||
"github.com/prysmaticlabs/prysm/shared/promptutil"
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/urfave/cli/v2"
|
||||
)
|
||||
@@ -41,7 +41,7 @@ func VerifyTosAcceptedOrPrompt(ctx *cli.Context) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
if fileutil.FileExists(filepath.Join(ctx.String(cmd.DataDirFlag.Name), acceptTosFilename)) {
|
||||
if file.FileExists(filepath.Join(ctx.String(cmd.DataDirFlag.Name), acceptTosFilename)) {
|
||||
return nil
|
||||
}
|
||||
if ctx.Bool(cmd.AcceptTosFlag.Name) {
|
||||
@@ -49,7 +49,7 @@ func VerifyTosAcceptedOrPrompt(ctx *cli.Context) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
input, err := promptutil.DefaultPrompt(au.Bold(acceptTosPromptText).String(), "decline")
|
||||
input, err := prompt.DefaultPrompt(au.Bold(acceptTosPromptText).String(), "decline")
|
||||
if err != nil {
|
||||
return errors.New(acceptTosPromptErrText)
|
||||
}
|
||||
@@ -64,16 +64,16 @@ func VerifyTosAcceptedOrPrompt(ctx *cli.Context) error {
|
||||
// saveTosAccepted creates a file when Tos accepted.
|
||||
func saveTosAccepted(ctx *cli.Context) {
|
||||
dataDir := ctx.String(cmd.DataDirFlag.Name)
|
||||
dataDirExists, err := fileutil.HasDir(dataDir)
|
||||
dataDirExists, err := file.HasDir(dataDir)
|
||||
if err != nil {
|
||||
log.WithError(err).Warnf("error checking directory: %s", dataDir)
|
||||
}
|
||||
if !dataDirExists {
|
||||
if err := fileutil.MkdirAll(dataDir); err != nil {
|
||||
if err := file.MkdirAll(dataDir); err != nil {
|
||||
log.WithError(err).Warnf("error creating directory: %s", dataDir)
|
||||
}
|
||||
}
|
||||
if err := fileutil.WriteFile(filepath.Join(dataDir, acceptTosFilename), []byte("")); err != nil {
|
||||
if err := file.WriteFile(filepath.Join(dataDir, acceptTosFilename), []byte("")); err != nil {
|
||||
log.WithError(err).Warnf("error writing %s to file: %s", cmd.AcceptTosFlag.Name,
|
||||
filepath.Join(dataDir, acceptTosFilename))
|
||||
}
|
||||
|
||||
@@ -25,14 +25,14 @@ func TestVerifyTosAcceptedOrPrompt(t *testing.T) {
|
||||
os.Stdin = tmpfile
|
||||
defer func() { os.Stdin = origStdin }()
|
||||
|
||||
// prompt decline
|
||||
// userprompt decline
|
||||
_, err = tmpfile.Write([]byte("decline"))
|
||||
require.NoError(t, err)
|
||||
_, err = tmpfile.Seek(0, 0)
|
||||
require.NoError(t, err)
|
||||
require.ErrorContains(t, "you have to accept Terms and Conditions", VerifyTosAcceptedOrPrompt(context))
|
||||
|
||||
// prompt accept
|
||||
// userprompt accept
|
||||
err = tmpfile.Truncate(0)
|
||||
require.NoError(t, err)
|
||||
_, err = tmpfile.Seek(0, 0)
|
||||
|
||||
Reference in New Issue
Block a user