func check(cmd *cobra.Command, args []string) error { if err := InitializeConfig(checkCmd); err != nil { return err } site := hugolib.Site{} return site.Analyze() }
"github.com/spf13/hugo/hugolib" "syscall" ) func init() { check.AddCommand(limit) } var check = &cobra.Command{ Use: "check", Short: "Check content in the source directory", Long: `Hugo will perform some basic analysis on the content provided and will give feedback.`, Run: func(cmd *cobra.Command, args []string) { InitializeConfig() site := hugolib.Site{Config: *Config} site.Analyze() }, } var limit = &cobra.Command{ Use: "ulimit", Short: "Check system ulimit settings", Long: `Hugo will inspect the current ulimit settings on the system. This is primarily to ensure that Hugo can watch enough files on some OSs`, Run: func(cmd *cobra.Command, args []string) { var rLimit syscall.Rlimit err := syscall.Getrlimit(syscall.RLIMIT_NOFILE, &rLimit) if err != nil { fmt.Println("Error Getting Rlimit ", err) }
func main() { flag.Usage = usage flag.Parse() if *help { usage() } if *version { fmt.Println("Hugo Static Site Generator v0.8") return } config := hugolib.SetupConfig(cfgfile, source) config.BuildDrafts = *draft config.UglyUrls = *uglyUrls config.Verbose = *verbose if *baseUrl != "" { config.BaseUrl = *baseUrl } else if *server { config.BaseUrl = "http://localhost:" + *port } if *destination != "" { config.PublishDir = *destination } if *cpuprofile != 0 { f, err := os.Create("/tmp/hugo-cpuprofile") if err != nil { panic(err) } pprof.StartCPUProfile(f) defer pprof.StopCPUProfile() for i := 0; i < *cpuprofile; i++ { _, _ = buildSite(config) } } // Copy Static to Destination first err := fsync.SyncDel(config.GetAbsPath(config.PublishDir+"/"), config.GetAbsPath(config.StaticDir+"/")) if err != nil { log.Fatalf("Error copying static files to %s: %v", config.GetAbsPath(config.PublishDir), err) } if *checkMode { site := hugolib.Site{Config: *config} site.Analyze() os.Exit(0) } if *watchMode { fmt.Println("Watching for changes. Press ctrl+c to stop") _, err = buildSite(config) if err != nil { fmt.Println(err) return } err := NewWatcher(config, *port, *server) if err != nil { fmt.Println(err) } } if _, err = buildSite(config); err != nil { fmt.Println(err) } if *server { serve(*port, config) } }