Skip to content

Commit

Permalink
fix: wrong error message when shopware-extension yaml cannot be read, f…
Browse files Browse the repository at this point in the history
…ixes #412
  • Loading branch information
shyim committed Oct 26, 2024
1 parent 6d27c74 commit f5fa380
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
2 changes: 1 addition & 1 deletion extension/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ type Config struct {
}

func readExtensionConfig(dir string) (*Config, error) {
errorFormat := "readExtensionConfig: %v"
errorFormat := "file: " + dir + "/.shopware-extension.yml: %v"
config := &Config{}
config.Build.Zip.Assets.Enabled = true
config.Build.Zip.Composer.Enabled = true
Expand Down
4 changes: 3 additions & 1 deletion extension/platform.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ import (
"github.com/FriendsOfShopware/shopware-cli/version"
)

var ErrPlatformInvalidType = errors.New("invalid composer type")

type PlatformPlugin struct {
path string
composer platformComposerJson
Expand Down Expand Up @@ -51,7 +53,7 @@ func newPlatformPlugin(path string) (*PlatformPlugin, error) {
}

if composerJson.Type != ComposerTypePlugin {
return nil, fmt.Errorf("newPlatformPlugin: composer.json is not type of shopware-platform-plugin")
return nil, ErrPlatformInvalidType
}

cfg, err := readExtensionConfig(path)
Expand Down
7 changes: 6 additions & 1 deletion extension/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"archive/zip"
"bytes"
"context"
"errors"
"fmt"
"os"
"strings"
Expand Down Expand Up @@ -38,7 +39,11 @@ func GetExtensionByFolder(path string) (Extension, error) {

ext, err := newPlatformPlugin(path)
if err != nil {
ext, err = newShopwareBundle(path)
if errors.Is(err, ErrPlatformInvalidType) {
ext, err = newShopwareBundle(path)
} else {
return nil, err
}
}

return ext, err
Expand Down

0 comments on commit f5fa380

Please sign in to comment.