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
This commit is contained in:
Anthony Fok 2015-12-03 12:02:38 -07:00
parent 69c28985ea
commit cd062623bd
2 changed files with 8 additions and 3 deletions

View file

@ -310,9 +310,10 @@ func InitializeConfig(subCmdVs ...*cobra.Command) error {
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 != "" {

View file

@ -148,6 +148,10 @@ func server(cmd *cobra.Command, args []string) error {
viper.Set("PublishDir", "/")
}
if serverCmd.Flags().Lookup("noTimes").Changed {
viper.Set("NoTimes", NoTimes)
}
if err := build(serverWatch); err != nil {
return err
}