Skip to content

Commit

Permalink
[publisher] Support not existing example directory
Browse files Browse the repository at this point in the history
  • Loading branch information
IceflowRE committed Jan 15, 2024
1 parent 4b84f06 commit 2e0ed62
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
9 changes: 6 additions & 3 deletions publisher/addon.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,12 @@ func (addon *addon) Zip(outputFile string) error {
return err
}
exampleDir := filepath.Join(addon.ProjectPath(), "examples", addon.Id())
err = zipDir(zw, exampleDir, filepath.Join("examples", addon.Id()))
if err != nil {
return err
// zip example directory only if it exists
if _, err := os.Stat(exampleDir); err == nil {
err = zipDir(zw, exampleDir, filepath.Join("examples", addon.Id()))
if err != nil {
return err
}
}

err = zipFile(zw, filepath.Join(addon.ProjectPath(), "LICENSE.md"), filepath.Join("addons", addon.Id(), "LICENSE.md"))
Expand Down
3 changes: 3 additions & 0 deletions publisher/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ import (

func zipDir(zw *zip.Writer, src string, dest string) error {
return filepath.WalkDir(src, func(path string, d fs.DirEntry, err error) error {
if err != nil {
return err
}
rel, _ := filepath.Rel(src, path)
destPath := filepath.Join(dest, rel)
if d.IsDir() {
Expand Down

0 comments on commit 2e0ed62

Please sign in to comment.