Fix hugo server "Watching for changes" path display - hugo - [fork] hugo port for 9front
(HTM) git clone git@git.drkhsh.at/hugo.git
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) Submodules
(DIR) README
(DIR) LICENSE
---
(DIR) commit de82404d35bc0673ca4fe5c400945b3fc4e9aae2
(DIR) parent a1d232f4b674dcdc7757ccc3bdae2f95f0733720
(HTM) Author: Anthony Fok <foka@debian.org>
Date: Sat, 19 Dec 2015 05:19:31 -0700
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
Diffstat:
M commands/hugo.go | 3 ++-
M commands/server.go | 2 +-
M helpers/path.go | 2 +-
3 files changed, 4 insertions(+), 3 deletions(-)
---
(DIR) diff --git a/commands/hugo.go b/commands/hugo.go
@@ -329,7 +329,8 @@ func InitializeConfig(subCmdVs ...*cobra.Command) error {
}
if Source != "" {
- viper.Set("WorkingDir", Source)
+ dir, _ := filepath.Abs(Source)
+ viper.Set("WorkingDir", dir)
} else {
dir, _ := os.Getwd()
viper.Set("WorkingDir", dir)
(DIR) diff --git a/commands/server.go b/commands/server.go
@@ -159,7 +159,7 @@ func server(cmd *cobra.Command, args []string) error {
// Watch runs its own server as part of the routine
if serverWatch {
watchDirs := getDirList()
- baseWatchDir := helpers.AbsPathify(viper.GetString("WorkingDir"))
+ baseWatchDir := viper.GetString("WorkingDir")
for i, dir := range watchDirs {
watchDirs[i], _ = helpers.GetRelativePath(dir, baseWatchDir)
}
(DIR) diff --git a/helpers/path.go b/helpers/path.go
@@ -130,7 +130,7 @@ func AbsPathify(inPath string) string {
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))
}