Skip to content

Commit

Permalink
Merge pull request #1651 from onflow/chasefleming/init-gitignore
Browse files Browse the repository at this point in the history
Create gitignore file for imports and emulator key
  • Loading branch information
chasefleming authored Jun 11, 2024
2 parents ebbf96e + f7f6fb5 commit 9f8ace5
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions internal/super/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,22 @@ func create(
return &setupResult{targetDir: targetDir}, nil
}

func updateGitignore(targetDir string) error {
gitignorePath := filepath.Join(targetDir, ".gitignore")
f, err := os.OpenFile(gitignorePath, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644)
if err != nil {
return err
}
defer f.Close()

_, err = f.WriteString("\n# flow\nemulator-account.pkey\nimports\n")
if err != nil {
return err
}

return nil
}

func createConfigOnly(targetDir string, readerWriter flowkit.ReaderWriter) error {
params := config.InitConfigParameters{
ServiceKeySigAlgo: "ECDSA_P256",
Expand All @@ -130,6 +146,11 @@ func createConfigOnly(targetDir string, readerWriter flowkit.ReaderWriter) error
return err
}

err = updateGitignore(targetDir)
if err != nil {
return err
}

return nil
}

Expand Down Expand Up @@ -235,6 +256,11 @@ func startInteractiveSetup(
return "", err
}

err = updateGitignore(tempDir)
if err != nil {
return "", err
}

// Move the temp directory to the target directory
err = os.Rename(tempDir, targetDir)
if err != nil {
Expand Down

0 comments on commit 9f8ace5

Please sign in to comment.