mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-15 20:44:01 +02:00
Improve "watching for ..." logging
This commit is contained in:
@@ -450,37 +450,27 @@ func prettifyPath(in string, b filepathPathBridge) string {
|
||||
return b.Join(b.Dir(in), name, "index"+ext)
|
||||
}
|
||||
|
||||
// RemoveSubpaths takes a list of paths and removes everything that
|
||||
// contains another path in the list as a prefix. Ignores any empty
|
||||
// strings. Used mostly for logging.
|
||||
//
|
||||
// e.g. ["hello/world", "hello", "foo/bar", ""] -> ["hello", "foo/bar"]
|
||||
func RemoveSubpaths(paths []string) []string {
|
||||
a := make([]string, 0)
|
||||
for _, cur := range paths {
|
||||
// ignore trivial case
|
||||
if cur == "" {
|
||||
continue
|
||||
}
|
||||
|
||||
isDupe := false
|
||||
for i, old := range a {
|
||||
if strings.HasPrefix(cur, old) {
|
||||
isDupe = true
|
||||
break
|
||||
} else if strings.HasPrefix(old, cur) {
|
||||
a[i] = cur
|
||||
isDupe = true
|
||||
break
|
||||
// Extract the root paths from the supplied list of paths.
|
||||
// The resulting root path will not contain any file separators, but there
|
||||
// may be duplicates.
|
||||
// So "/content/section/" becomes "content"
|
||||
func ExtractRootPaths(paths []string) []string {
|
||||
r := make([]string, len(paths))
|
||||
for i, p := range paths {
|
||||
root := filepath.ToSlash(p)
|
||||
if strings.Contains(root, "/") {
|
||||
sections := strings.Split(root, "/")
|
||||
for _, section := range sections {
|
||||
if section != "" {
|
||||
root = section
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if !isDupe {
|
||||
a = append(a, cur)
|
||||
}
|
||||
r[i] = root
|
||||
}
|
||||
return r
|
||||
|
||||
return a
|
||||
}
|
||||
|
||||
// FindCWD returns the current working directory from where the Hugo
|
||||
|
Reference in New Issue
Block a user