fix nil ptr on no previous file

This commit is contained in:
bel
2023-10-15 10:39:01 -06:00
parent 236355b69d
commit 46e62dc485

View File

@@ -245,7 +245,7 @@ func edit(dry bool, filepaths []string) error {
return err
}
outputPath := target
if info, _ := os.Stat(target); info.ModTime() != lastModified[target] {
if info, _ := os.Stat(target); info != nil && info.ModTime() != lastModified[target] {
outputPath = fmt.Sprintf("%s.%s.%s", outputPath, uuid.New().String(), path.Ext(outputPath))
}
if err := ioutil.WriteFile(outputPath, c, os.ModePerm); err != nil {