Skip to content

Commit

Permalink
fix var name, fix embedded assets check
Browse files Browse the repository at this point in the history
  • Loading branch information
wxiaoguang committed Apr 9, 2023
1 parent 9e447e0 commit bbfef58
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
8 changes: 7 additions & 1 deletion cmd/embedded.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,12 @@ func runViewDo(c *cli.Context) error {
return err
}

if len(assets) == 0 {
return fmt.Errorf("no files matched the given pattern")
} else if len(assets) > 1 {
return fmt.Errorf("too many files matched the given pattern, try to be more specific")
}

data, err := assets[0].Section.AssetFS.ReadFile(assets[0].Name)
if err != nil {
return fmt.Errorf("%s: %w", assets[0].Path, err)
Expand Down Expand Up @@ -288,7 +294,7 @@ func buildAssetList(sec *section, globs []glob.Glob, c *cli.Context) []asset {
files, err := sec.AssetFS.ListFiles(".", true)
if err != nil {
log.Error("Error listing files in %q: %v", sec.Path, err)
return results
return nil
}
for _, name := range files {
if sec.Path == "public" &&
Expand Down
6 changes: 3 additions & 3 deletions modules/templates/mailer.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,13 @@ func Mailer(ctx context.Context) (*texttmpl.Template, *template.Template) {
}

for _, assetPath := range assetPaths {
content, providerName, err := assetFS.ReadLayeredFile(assetPath)
content, layerName, err := assetFS.ReadLayeredFile(assetPath)
if err != nil {
log.Warn("Failed to read mail template %s: %v (by %s)", assetPath, err, providerName)
log.Warn("Failed to read mail template %s: %v (by %s)", assetPath, err, layerName)
continue
}
tmplName := strings.TrimPrefix(strings.TrimSuffix(assetPath, ".tmpl"), "mail/")
log.Debug("Adding mail template %s: %s (by %s)", tmplName, assetPath, providerName)
log.Debug("Adding mail template %s: %s (by %s)", tmplName, assetPath, layerName)
buildSubjectBodyTemplate(subjectTemplates, bodyTemplates, tmplName, content)
}
}
Expand Down

0 comments on commit bbfef58

Please sign in to comment.