Skip to content
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

Add default .upignore creation to project setup #747

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
25 changes: 23 additions & 2 deletions internal/setup/setup.go
Expand Up @@ -75,7 +75,7 @@ func Create() error {

println()

// confirm
// confirm create new project
var ok bool
err := survey.AskOne(&survey.Confirm{
Message: fmt.Sprintf("No up.json found, create a new project?"),
Expand Down Expand Up @@ -106,7 +106,28 @@ func Create() error {
}

b, _ := json.MarshalIndent(c, "", " ")
return ioutil.WriteFile("up.json", b, 0644)
err = ioutil.WriteFile("up.json", b, 0644)
if err != nil {
return err
}

// confirm create .upignore
err = survey.AskOne(&survey.Confirm{
Message: fmt.Sprintf("Would you like to add an .upignore?"),
Default: true,
}, &ok, nil)

if err != nil {
return nil
}

if !ok {
return errors.New("aborted")
}

defaultIgnore := ".*\n"
b = []byte(defaultIgnore)
return ioutil.WriteFile(".upignore", b, 0644)
}

// defaultName returns the default app name.
Expand Down