Skip to content

Commit

Permalink
fix: make exit calls only from main package
Browse files Browse the repository at this point in the history
  • Loading branch information
ivanilves committed Oct 15, 2022
1 parent 3572e99 commit 3ca0067
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
4 changes: 3 additions & 1 deletion cmd/ttg/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,11 @@ func main() {
}

if outFile != "" {
if err := file.WriteAndExit(outFile, entries[selected]); err != nil {
if err := file.Write(outFile, entries[selected]); err != nil {
log.Fatalf("failed to write output file: %s", err.Error())
}

os.Exit(0)
}

shell.Spawn(entries[selected])
Expand Down
6 changes: 1 addition & 5 deletions pkg/file/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,8 @@ import (
"os"
)

func WriteAndExit(outFile string, path string) error {
func Write(outFile string, path string) error {
err := os.WriteFile(outFile, []byte(path), 0644)

if err == nil {
os.Exit(0)
}

return err
}

0 comments on commit 3ca0067

Please sign in to comment.