Skip to content

Commit

Permalink
fix: snippet file cleanup matching, fixes #392
Browse files Browse the repository at this point in the history
  • Loading branch information
shyim committed Sep 2, 2024
1 parent cb14a19 commit 69893a9
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 10 deletions.
19 changes: 10 additions & 9 deletions cmd/project/ci.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
"github.com/FriendsOfShopware/shopware-cli/logging"
"github.com/FriendsOfShopware/shopware-cli/shop"
"github.com/spf13/cobra"
"golang.org/x/text/language"
)

// cleanupPaths are paths that are not nesscarry for the production build.
Expand Down Expand Up @@ -339,23 +340,23 @@ func cleanupAdministrationFiles(ctx context.Context, folder string) error {
return nil
}

if filepath.Ext(path) != ".json" {
fileExt := filepath.Ext(path)

if fileExt != ".json" {
return nil
}

if filepath.Base(filepath.Dir(path)) != "snippet" {
languageName := strings.TrimSuffix(filepath.Base(path), fileExt)

if language.Make(languageName).IsRoot() {
return nil
}

name := filepath.Base(path)
extension := filepath.Ext(name)
language := name[0 : len(name)-len(extension)]

if _, ok := snippetFiles[language]; !ok {
snippetFiles[language] = []string{}
if _, ok := snippetFiles[languageName]; !ok {
snippetFiles[languageName] = []string{}
}

snippetFiles[language] = append(snippetFiles[language], path)
snippetFiles[languageName] = append(snippetFiles[languageName], path)

return nil
})
Expand Down
3 changes: 2 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ require (
github.com/wI2L/jsondiff v0.6.0
github.com/yuin/goldmark v1.7.4
go.uber.org/zap v1.27.0
golang.org/x/text v0.17.0
gopkg.in/yaml.v3 v3.0.1
)

Expand All @@ -35,7 +36,7 @@ require (
github.com/tidwall/match v1.1.1 // indirect
github.com/tidwall/pretty v1.2.1 // indirect
github.com/tidwall/sjson v1.2.5 // indirect
golang.org/x/sync v0.5.0 // indirect
golang.org/x/sync v0.8.0 // indirect
)

require (
Expand Down
4 changes: 4 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,8 @@ golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJ
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.5.0 h1:60k92dhOjHxJkrqnwsfl8KuaHbn/5dl0lUPUklKo3qE=
golang.org/x/sync v0.5.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/sync v0.8.0 h1:3NFvSEYkUoMifnESzZl15y791HH1qU2xm6eCJU5ZPXQ=
golang.org/x/sync v0.8.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/sys v0.0.0-20181122145206-62eef0e2fa9b/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
Expand All @@ -152,6 +154,8 @@ golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ=
golang.org/x/text v0.17.0 h1:XtiM5bkSOt+ewxlOE/aE/AKEHibwj/6gvWMl9Rsh0Qc=
golang.org/x/text v0.17.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
Expand Down

0 comments on commit 69893a9

Please sign in to comment.