mirror of
https://github.com/gohugoio/hugo.git
synced 2024-12-26 05:01:26 +00:00
Add configurable list to ignore files in server watch
The following inside `config.toml` will ignore files ending with `.foo` and `.boo`. ``` watchIgnoreFiles = [ "\\.foo$", "\\.boo$" ] ``` The above is is a list of Reqular Expressions, but note the escaping of the `\` to make TOML happy. Fixes #1189
This commit is contained in:
parent
cc5d63c37a
commit
bed227886b
1 changed files with 11 additions and 0 deletions
|
@ -15,10 +15,12 @@ package source
|
|||
|
||||
import (
|
||||
"bytes"
|
||||
"github.com/spf13/viper"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"regexp"
|
||||
"strings"
|
||||
|
||||
"github.com/spf13/hugo/helpers"
|
||||
|
@ -146,5 +148,14 @@ func isNonProcessablePath(filePath string) bool {
|
|||
return true
|
||||
}
|
||||
|
||||
ignoreFiles := viper.GetStringSlice("WatchIgnoreFiles")
|
||||
if len(ignoreFiles) > 0 {
|
||||
for _, ignorePattern := range ignoreFiles {
|
||||
match, _ := regexp.MatchString(ignorePattern, filePath)
|
||||
if match {
|
||||
return true
|
||||
}
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue