Skip to content

Commit

Permalink
Add configurable list to ignore files in server watch
Browse files Browse the repository at this point in the history
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 gohugoio#1189
  • Loading branch information
bep committed Jun 3, 2015
1 parent cc5d63c commit bed2278
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions source/filesystem.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
}

0 comments on commit bed2278

Please sign in to comment.