diff options
author | Dylan MacKenzie <[email protected]> | 2015-04-01 21:40:29 -0700 |
---|---|---|
committer | bep <[email protected]> | 2015-04-02 12:52:08 +0200 |
commit | 99a18b21fcc2523015c071b8915cae00a83842b5 (patch) | |
tree | 28d6ace240d1c9813a661c4449dc4fb54f3fa6be /helpers/path_test.go | |
parent | 72aa516c756510e19a19a81419879fb31e6952f1 (diff) | |
download | hugo-99a18b21fcc2523015c071b8915cae00a83842b5.tar.gz hugo-99a18b21fcc2523015c071b8915cae00a83842b5.zip |
List directories being watched when server is run
Fixes part of issue 1030. Previously hugo only listed the content
directory as being watched. Now we list all files being watched
according to `commands.getDirList()`. We also introduce a RemoveSubpaths
function and test in the helpers module to reduce noise in the command
line output by not showing subdirectories of ones already being watched.
For example, instead of:
`Watching for changes in $HOME/blog/content`
We get:
`Watching for changes in
$HOME/blog/{data,content,layouts,static,themes/my-theme}`
Diffstat (limited to 'helpers/path_test.go')
-rw-r--r-- | helpers/path_test.go | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/helpers/path_test.go b/helpers/path_test.go index 66fe5457f..f0c8ef6e2 100644 --- a/helpers/path_test.go +++ b/helpers/path_test.go @@ -2,10 +2,10 @@ package helpers import ( "fmt" - "github.com/spf13/viper" "io/ioutil" "os" "path/filepath" + "reflect" "runtime" "strconv" "strings" @@ -13,6 +13,7 @@ import ( "time" "github.com/spf13/afero" + "github.com/spf13/viper" ) func TestMakePath(t *testing.T) { @@ -545,6 +546,14 @@ func TestPrettifyPath(t *testing.T) { } +func TestRemoveSubpaths(t *testing.T) { + got := RemoveSubpaths([]string{"hello", "hello/world", "foo/bar", ""}) + expect := []string{"hello", "foo/bar"} + if !reflect.DeepEqual(got, expect) { + t.Errorf("Test %d failed. Expected %q but got %q", expect, got) + } +} + func TestFindCWD(t *testing.T) { type test struct { expectedDir string |