mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-15 20:44:01 +02:00
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}`
This commit is contained in:
@@ -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
|
||||
|
Reference in New Issue
Block a user