hugo

Unnamed repository; edit this file 'description' to name the repository.

git clone git://git.shimmy1996.com/hugo.git
commit bed227886be3abacb7beb14c40b88139193114de
parent cc5d63c37ae0b7387864a81b4ae6e0fc2895f8a3
Author: bep <bjorn.erik.pedersen@gmail.com>
Date:   Wed,  3 Jun 2015 13:37:57 +0200

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

Diffstat:
Msource/filesystem.go | 11+++++++++++
1 file changed, 11 insertions(+), 0 deletions(-)
diff --git a/source/filesystem.go b/source/filesystem.go
@@ -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
 }