Skip to content

Commit

Permalink
Fix theme upload bug
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisbutcher committed Aug 17, 2016
1 parent 3265ce5 commit 13995ab
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
21 changes: 21 additions & 0 deletions commands/upload.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
package commands

import (
"fmt"
"os"
"path/filepath"
"strings"

"github.com/Shopify/themekit"
"github.com/Shopify/themekit/theme"
)

// UploadCommand add file(s) to theme
func UploadCommand(args Args) chan bool {
files := make(chan themekit.AssetEvent)
args.Filenames = extractFilenames(args, args.Filenames)
go ReadAndPrepareFiles(args, files)

done, events := args.ThemeClient.Process(files)
Expand Down Expand Up @@ -37,3 +43,18 @@ func loadAsset(args Args, filename string) (asset theme.Asset, err error) {

return theme.LoadAsset(root, filename)
}

func extractFilenames(args Args, filenames []string) []string {
if len(filenames) > 0 {
return filenames
}
filepath.Walk(args.Directory, func(path string, info os.FileInfo, err error) error {
if !info.IsDir() {
root := fmt.Sprintf("%s%s", args.Directory, string(filepath.Separator))
name := strings.Replace(path, root, "", -1)
filenames = append(filenames, name)
}
return nil
})
return filenames
}
2 changes: 1 addition & 1 deletion version.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
)

// TKVersion ... TODO
var TKVersion = Version{Major: 0, Minor: 4, Patch: 1}
var TKVersion = Version{Major: 0, Minor: 4, Patch: 2}

// ThemeKitVersion ... TODO
var ThemeKitVersion = TKVersion.String()
Expand Down

0 comments on commit 13995ab

Please sign in to comment.