fork of anirudh.fi/vite that uses chroma for hl
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Check to ensure we don't overwrite existing files

+11 -5
+11 -5
commands/new.go
··· 1 1 package commands 2 2 3 3 import ( 4 + "errors" 4 5 "fmt" 5 6 "os" 6 7 "path/filepath" ··· 20 21 date: %s 21 22 ---`, url, time.Now().Format("2006-01-02")) 22 23 23 - _, err := os.Create(path) 24 - if err != nil { 25 - return err 24 + if _, err := os.Stat(path); errors.Is(err, os.ErrNotExist) { 25 + _, err := os.Create(path) 26 + if err != nil { 27 + return err 28 + } 29 + os.WriteFile(path, []byte(content), 0755) 30 + fmt.Printf("vite: created new post at %s\n", path) 31 + return nil 26 32 } 27 - os.WriteFile(path, []byte(content), 0755) 28 - fmt.Printf("vite: created new post at %s\n", path) 33 + 34 + fmt.Printf("error: %s already exists\n", path) 29 35 return nil 30 36 }