Skip to content

Commit

Permalink
fix: zipping of extension to correct names
Browse files Browse the repository at this point in the history
  • Loading branch information
shyim committed Jan 15, 2022
1 parent efd1936 commit c57ea12
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
16 changes: 12 additions & 4 deletions cmd/extension_zip.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,14 @@ var extensionZipCmd = &cobra.Command{

// Create temp dir
tempDir, err := ioutil.TempDir("", "extension")
extName, err := ext.GetName()
if err != nil {
log.Fatalln(err)
}

extDir := fmt.Sprintf("%s/%s/", tempDir, extName)

err = os.Mkdir(extDir, os.ModePerm)
tempDir = tempDir + "/"

if err != nil {
Expand All @@ -68,9 +76,9 @@ var extensionZipCmd = &cobra.Command{

// Extract files using strategy
if disableGit {
err = cp.Copy(path, tempDir)
err = cp.Copy(path, extDir)
} else {
tag, err = extension.GitCopyFolder(path, tempDir)
tag, err = extension.GitCopyFolder(path, extDir)
}

// User input wins
Expand All @@ -82,14 +90,14 @@ var extensionZipCmd = &cobra.Command{
log.Fatalln(err)
}

err = extension.PrepareFolderForZipping(tempDir, ext)
err = extension.PrepareFolderForZipping(extDir, ext)

if err != nil {
log.Fatalln(err)
}

// Cleanup not wanted files
err = extension.CleanupExtensionFolder(tempDir)
err = extension.CleanupExtensionFolder(extDir)
if err != nil {
log.Fatalln(err)
}
Expand Down
4 changes: 3 additions & 1 deletion extension/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"github.com/hashicorp/go-version"
"io/ioutil"
"os"
"strings"
)

func GetExtensionByFolder(path string) (Extension, error) {
Expand Down Expand Up @@ -49,7 +50,8 @@ func GetExtensionByZip(filePath string) (Extension, error) {
return nil, err
}

return GetExtensionByFolder(dir)
extName := strings.Split(file.File[0].Name, "/")[0]
return GetExtensionByFolder(fmt.Sprintf("%s/%s", dir, extName))
}

type extensionTranslated struct {
Expand Down

0 comments on commit c57ea12

Please sign in to comment.