Skip to content

Commit

Permalink
Remove additional output when initializing project (#1766)
Browse files Browse the repository at this point in the history
  • Loading branch information
schnie authored Dec 15, 2024
1 parent dce037b commit 69c034c
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 19 deletions.
16 changes: 1 addition & 15 deletions cmd/airflow.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@ astro dev init --from-template

configReinitProjectConfigMsg = "Reinitialized existing Astro project in %s\n"
configInitProjectConfigMsg = "Initialized empty Astro project in %s\n"
changeDirectoryMsg = "To begin developing, change to your project directory with `cd %s`\n"

// this is used to monkey patch the function in order to write unit test cases
containerHandlerInit = airflow.ContainerHandlerInit
Expand Down Expand Up @@ -460,12 +459,6 @@ func airflowInit(cmd *cobra.Command, args []string) error {
}
projectName = name

// Save the directory we are in when the init command is run.
initialDir, err := fileutil.GetWorkingDir()
if err != nil {
return err
}

if fromTemplate == "select-template" {
selectedTemplate, err := selectedTemplate()
if err != nil {
Expand Down Expand Up @@ -552,13 +545,6 @@ func airflowInit(cmd *cobra.Command, args []string) error {
fmt.Printf(configInitProjectConfigMsg, config.WorkingPath)
}

// If we started in a different directory, that means the positional argument for projectName was used.
// This means the users shell pwd is not the project directory, so we print a message
// to cd into the project directory.
if initialDir != config.WorkingPath {
fmt.Printf(changeDirectoryMsg, projectName)
}

return nil
}

Expand All @@ -580,7 +566,7 @@ func ensureProjectDirectory(args []string, workingPath, projectName string) (str

// If the project directory does not exist, create it.
if !projectDirExists {
err := os.Mkdir(newProjectPath, os.FileMode(directoryPermissions))
err := os.Mkdir(newProjectPath, os.FileMode(directoryPermissions)) //nolint:gosec
if err != nil {
return "", err
}
Expand Down
5 changes: 1 addition & 4 deletions cmd/airflow_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package cmd
import (
"bytes"
"errors"
"fmt"
"io"
"net/http"
"os"
Expand Down Expand Up @@ -481,16 +480,14 @@ func (s *AirflowSuite) TestAirflowInit() {

orgStdout := os.Stdout
defer func() { os.Stdout = orgStdout }()
r, w, _ := os.Pipe()
_, w, _ := os.Pipe()
os.Stdout = w

err := airflowInit(cmd, args)

w.Close()
out, _ := io.ReadAll(r)

s.NoError(err)
s.Contains(string(out), fmt.Sprintf(changeDirectoryMsg, args[0]))
})

s.Run("specify flag and positional argument for project name, resulting in error", func() {
Expand Down

0 comments on commit 69c034c

Please sign in to comment.