shithub: hugo

Download patch

ref: cd062623bd9eb1ded58b774086236ccc8130db8b
parent: 69c28985ea6ca58ebb0b34f30f9f43f42502d318
author: Anthony Fok <[email protected]>
date: Thu Dec 3 07:02:38 EST 2015

Fix crash with "config", "check" and "benchmark"

The crash was introduced by commit 00d04774 in PR #1652
where access to NoTimes was attempted even though --noTimes
was not defined for the config, check and benchmark commands.

Special thanks to @bep for the heads-up!

See also #1624 - CLI UX: Flags shouldn't be global

--- a/commands/hugo.go
+++ b/commands/hugo.go
@@ -310,9 +310,10 @@
 		if cmdV.Flags().Lookup("ignoreCache").Changed {
 			viper.Set("IgnoreCache", IgnoreCache)
 		}
-		if cmdV.Flags().Lookup("noTimes").Changed {
-			viper.Set("NoTimes", NoTimes)
-		}
+	}
+
+	if hugoCmdV.Flags().Lookup("noTimes").Changed {
+		viper.Set("NoTimes", NoTimes)
 	}
 
 	if BaseURL != "" {
--- a/commands/server.go
+++ b/commands/server.go
@@ -148,6 +148,10 @@
 		viper.Set("PublishDir", "/")
 	}
 
+	if serverCmd.Flags().Lookup("noTimes").Changed {
+		viper.Set("NoTimes", NoTimes)
+	}
+
 	if err := build(serverWatch); err != nil {
 		return err
 	}