Skip to content

Commit

Permalink
Fix 'no such file or directory error' when --rm-dist and no directory
Browse files Browse the repository at this point in the history
  • Loading branch information
k1LoW committed Feb 17, 2021
1 parent c3cffef commit d19b44f
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions cmd/doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,14 +78,16 @@ var docCmd = &cobra.Command{
}

if rmDist && c.DocPath != "" {
docs, err := ioutil.ReadDir(c.DocPath)
if err != nil {
return errors.WithStack(err)
}
for _, f := range docs {
if err := os.RemoveAll(filepath.Join(c.DocPath, f.Name())); err != nil {
if _, err := os.Lstat(c.DocPath); err == nil {
docs, err := ioutil.ReadDir(c.DocPath)
if err != nil {
return errors.WithStack(err)
}
for _, f := range docs {
if err := os.RemoveAll(filepath.Join(c.DocPath, f.Name())); err != nil {
return errors.WithStack(err)
}
}
}
}

Expand Down

0 comments on commit d19b44f

Please # to comment.