Skip to content

Commit

Permalink
Attempt remove of existing folder before rename
Browse files Browse the repository at this point in the history
  • Loading branch information
AlinaNova21 committed Feb 25, 2021
1 parent 10cf230 commit abbb9b1
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions install/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,10 @@ func Node(version string) error {
name = strings.TrimSuffix(name, ".tar.gz")
}
log.Print(name)
err = os.Rename(fmt.Sprintf("deps/%s", name), "deps/node")
if err != nil {
if err := os.RemoveAll("deps/node"); err != nil && !os.IsNotExist(err) {
return err
}
if err := os.Rename(fmt.Sprintf("deps/%s", name), "deps/node"); err != nil {
return err
}
return nil
Expand Down Expand Up @@ -165,8 +167,10 @@ Loop:
os.Remove(file)
name := strings.TrimSuffix(file, ".tar.gz")
log.Print(name)
err = os.Rename(fmt.Sprintf("deps/%s", name), "deps/yarn")
if err != nil {
if err := os.RemoveAll("deps/yarn"); err != nil && !os.IsNotExist(err) {
return err
}
if err := os.Rename(fmt.Sprintf("deps/%s", name), "deps/yarn"); err != nil {
return err
}
return nil
Expand Down

0 comments on commit abbb9b1

Please sign in to comment.