mirror of
https://github.com/gohugoio/hugo.git
synced 2024-11-29 23:53:32 -05:00
Fix hugo server "Watching for changes" path display
especially when the given `--source` path is a relative directory. Also, when `--source` is specified, make WorkingDir an absolute path from the very beginning, to be consistent with the case when `--source` is not given. Otherwise, the function name helpers.AbsPathify(), which prepends WorkingDir to a relative path, does not really make sense. Fixes #1721
This commit is contained in:
parent
a1d232f4b6
commit
de82404d35
3 changed files with 4 additions and 3 deletions
|
@ -329,7 +329,8 @@ func InitializeConfig(subCmdVs ...*cobra.Command) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
if Source != "" {
|
if Source != "" {
|
||||||
viper.Set("WorkingDir", Source)
|
dir, _ := filepath.Abs(Source)
|
||||||
|
viper.Set("WorkingDir", dir)
|
||||||
} else {
|
} else {
|
||||||
dir, _ := os.Getwd()
|
dir, _ := os.Getwd()
|
||||||
viper.Set("WorkingDir", dir)
|
viper.Set("WorkingDir", dir)
|
||||||
|
|
|
@ -159,7 +159,7 @@ func server(cmd *cobra.Command, args []string) error {
|
||||||
// Watch runs its own server as part of the routine
|
// Watch runs its own server as part of the routine
|
||||||
if serverWatch {
|
if serverWatch {
|
||||||
watchDirs := getDirList()
|
watchDirs := getDirList()
|
||||||
baseWatchDir := helpers.AbsPathify(viper.GetString("WorkingDir"))
|
baseWatchDir := viper.GetString("WorkingDir")
|
||||||
for i, dir := range watchDirs {
|
for i, dir := range watchDirs {
|
||||||
watchDirs[i], _ = helpers.GetRelativePath(dir, baseWatchDir)
|
watchDirs[i], _ = helpers.GetRelativePath(dir, baseWatchDir)
|
||||||
}
|
}
|
||||||
|
|
|
@ -130,7 +130,7 @@ func AbsPathify(inPath string) string {
|
||||||
return filepath.Clean(inPath)
|
return filepath.Clean(inPath)
|
||||||
}
|
}
|
||||||
|
|
||||||
// todo consider move workingDir to argument list
|
// TODO(bep): Consider moving workingDir to argument list
|
||||||
return filepath.Clean(filepath.Join(viper.GetString("WorkingDir"), inPath))
|
return filepath.Clean(filepath.Join(viper.GetString("WorkingDir"), inPath))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue