Skip to content
This repository has been archived by the owner on Feb 24, 2024. It is now read-only.

Fix relative path finding (#982) #989

Merged
merged 3 commits into from
Mar 25, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions buffalo/cmd/build/archived_assets.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"io"
"os"
"path/filepath"
"strings"

"github.com/pkg/errors"
"github.com/sirupsen/logrus"
Expand Down Expand Up @@ -73,7 +72,11 @@ func (b *Builder) buildAssetsArchive() error {
}

if baseDir != "" {
header.Name = filepath.Join(baseDir, strings.TrimPrefix(path, source))
rel, err := filepath.Rel(source, path)
if err != nil {
return errors.WithStack(err)
}
header.Name = filepath.Join(baseDir, rel)
}

if info.IsDir() {
Expand Down
6 changes: 4 additions & 2 deletions generators/files.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,10 @@ func Find(path string) (Files, error) {
if info != nil && !info.IsDir() {
if filepath.Ext(p) == ".tmpl" {
f := File{ReadPath: p}
rel := strings.TrimPrefix(p, root)

rel, err := filepath.Rel(root, p)
if err != nil {
rel = strings.TrimPrefix(p, root)
}
paths := strings.Split(rel, string(os.PathSeparator))

li := len(paths) - 1
Expand Down