Skip to content

Commit

Permalink
Fix hugo server "Watching for changes" path display
Browse files Browse the repository at this point in the history
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
  • Loading branch information
anthonyfok committed Dec 19, 2015
1 parent a1d232f commit de82404
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
3 changes: 2 additions & 1 deletion commands/hugo.go
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion commands/server.go
Expand Up @@ -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)
}
Expand Down
2 changes: 1 addition & 1 deletion helpers/path.go
Expand Up @@ -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))
}

Expand Down

0 comments on commit de82404

Please sign in to comment.