commands: Move time notification to after any build errors

This allows error parsers (VSCode problemMatchers) to use the time notification as bounds for detecting errors.

Closes #8403
This commit is contained in:
John Hollowell 2021-07-05 04:38:54 -04:00 committed by GitHub
parent 07919d1ccb
commit 04dc469fbd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 29 additions and 7 deletions

View file

@ -236,12 +236,24 @@ func (sc *serverCmd) server(cmd *cobra.Command, args []string) error {
jww.WARN.Println("memstats error:", err)
}
// silence errors in cobra so we can handle them here
cmd.SilenceErrors = true
c, err := initializeConfig(true, true, &sc.hugoBuilderCommon, sc, cfgInit)
if err != nil {
cmd.PrintErrln("Error:", err.Error())
return err
}
if err := c.serverBuild(); err != nil {
err = func() error {
defer c.timeTrack(time.Now(), "Built")
err := c.serverBuild()
if err != nil {
cmd.PrintErrln("Error:", err.Error())
}
return err
}()
if err != nil {
return err
}