mirror of
https://github.com/gohugoio/hugo.git
synced 2025-04-27 14:10:31 +03:00
Move the mount duplicate filter to the modules package
Also simplify the mount validation logic. There are plenty of ways a user can create mount configs that behaves oddly.
This commit is contained in:
parent
edf9f0a354
commit
4b6c5eba30
6 changed files with 154 additions and 123 deletions
|
@ -15,7 +15,6 @@ package modules
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"path"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
|
@ -174,18 +173,7 @@ func ApplyProjectConfigDefaults(cfg config.Provider, mod Module) error {
|
|||
// Prepend the mounts from configuration.
|
||||
mounts = append(moda.mounts, mounts...)
|
||||
|
||||
// Remove duplicates
|
||||
seen := make(map[string]bool)
|
||||
tmp := mounts[:0]
|
||||
for _, m := range mounts {
|
||||
key := path.Join(m.Lang, m.Source, m.Target)
|
||||
if !seen[key] {
|
||||
tmp = append(tmp, m)
|
||||
}
|
||||
seen[key] = true
|
||||
}
|
||||
|
||||
moda.mounts = tmp
|
||||
moda.mounts = mounts
|
||||
|
||||
return nil
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue