Skip to content

Commit

Permalink
chore(cmd): p -> path
Browse files Browse the repository at this point in the history
  • Loading branch information
gabe565 committed Apr 11, 2024
1 parent 3241ef9 commit edf23d4
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions cmd/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,16 +200,16 @@ func openAndTemplate(conf *config.Config, w io.Writer, path string) error {
return openAndTemplateFile(conf, w, path)
}

func openAndTemplateFile(conf *config.Config, w io.Writer, p string) error {
f, err := os.Open(p)
func openAndTemplateFile(conf *config.Config, w io.Writer, path string) error {
f, err := os.Open(path)
if err != nil {
return err
}
defer func(f *os.File) {
_ = f.Close()
}(f)

log := log.With().Str("file", p).Logger()
log := log.With().Str("file", path).Logger()

s, err := templateReader(conf, f, log)
if err != nil {
Expand All @@ -224,7 +224,7 @@ func openAndTemplateFile(conf *config.Config, w io.Writer, p string) error {
_ = f.Close()

if conf.Inplace {
temp, err := os.CreateTemp("", "yampl_*_"+filepath.Base(p))
temp, err := os.CreateTemp("", "yampl_*_"+filepath.Base(path))
if err != nil {
return err
}
Expand All @@ -244,7 +244,7 @@ func openAndTemplateFile(conf *config.Config, w io.Writer, p string) error {
return err
}

if err := os.Rename(temp.Name(), p); err != nil {
if err := os.Rename(temp.Name(), path); err != nil {
log.Trace().Msg("failed to rename file, attempting to copy contents")

in, err := os.Open(temp.Name())
Expand All @@ -255,7 +255,7 @@ func openAndTemplateFile(conf *config.Config, w io.Writer, p string) error {
_ = in.Close()
}()

out, err := os.OpenFile(p, os.O_WRONLY|os.O_TRUNC, stat.Mode())
out, err := os.OpenFile(path, os.O_WRONLY|os.O_TRUNC, stat.Mode())
if err != nil {
return err
}
Expand Down

0 comments on commit edf23d4

Please sign in to comment.