Skip to content

Commit

Permalink
Merge pull request #17 from carapace-sh/fix-install
Browse files Browse the repository at this point in the history
windows: fix install
  • Loading branch information
rsteube authored Dec 8, 2024
2 parents 3337efc + 7d47246 commit c396b8a
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions swap_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,11 @@ func (c config) swap(source, target string) error {
}
}

c.Printf("moving current executable to %#v\n", old)
if err := os.Rename(target, old); err != nil {
return err
if _, err := os.Stat(target); err == nil {
c.Printf("moving current executable to %#v\n", old)
if err := os.Rename(target, old); err != nil {
return err
}
}

c.Printf("moving new executable to %#v\n", target)
Expand All @@ -33,8 +35,11 @@ func (c config) swap(source, target string) error {
return err
}

c.Printf("hiding %#v\n", old)
return hide(old)
if _, err := os.Stat(old); err == nil {
c.Printf("hiding %#v\n", old)
return hide(old)
}
return nil
}

func hide(path string) error {
Expand Down

0 comments on commit c396b8a

Please sign in to comment.