From 13995abc949178eda7a8adcbd067764a49b57ed4 Mon Sep 17 00:00:00 2001 From: Christopher Butcher Date: Wed, 17 Aug 2016 17:12:00 -0400 Subject: [PATCH] Fix theme upload bug --- commands/upload.go | 21 +++++++++++++++++++++ version.go | 2 +- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/commands/upload.go b/commands/upload.go index d2d192bc..23504846 100644 --- a/commands/upload.go +++ b/commands/upload.go @@ -1,6 +1,11 @@ package commands import ( + "fmt" + "os" + "path/filepath" + "strings" + "github.com/Shopify/themekit" "github.com/Shopify/themekit/theme" ) @@ -8,6 +13,7 @@ import ( // 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) @@ -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 +} diff --git a/version.go b/version.go index 0ac30052..a0ee4100 100644 --- a/version.go +++ b/version.go @@ -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()