8000 feat: friendly prompt when exec `envd init` by rrain7 · Pull Request #1562 · tensorchord/envd · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

feat: friendly prompt when exec envd init #1562

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 18, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions pkg/app/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,13 +116,22 @@ func isCondaEnvFile(file string) bool {
}

func initCommand(clicontext *cli.Context) error {
lang := strings.ToLower(clicontext.String("lang"))
buildContext, err := filepath.Abs(clicontext.Path("path"))
8000 force := clicontext.Bool("force")
if err != nil {
return err
}

filePath := filepath.Join(buildContext, "build.envd")
exists, err := fileutil.FileExists(filePath)
if err != nil {
return err
}
if exists && !force {
return errors.Errorf("build.envd already exists, use --force to overwrite it.\nOr you can run the command `envd up` to set up a new environment.")
}

lang := strings.ToLower(clicontext.String("lang"))
if !isValidLang(lang) {
startQuestion(LanguageChoice)
if len(selectionMap[LabelLanguage]) > 0 {
Expand All @@ -139,15 +148,6 @@ func initCommand(clicontext *cli.Context) error {
"init", telemetry.AddField("duration", time.Since(start).Seconds()))
}(time.Now())

filePath := filepath.Join(buildContext, "build.envd")
exists, err := fileutil.FileExists(filePath)
if err != nil {
return err
}
if exists && !force {
return errors.Errorf("build.envd already exists, use --force to overwrite it")
}

if lang == "python" {
err = InitPythonEnv(buildContext)
if err != nil {
Expand Down
0