diff options
author | Alexander Borsuk <me@alex.bio> | 2018-01-10 18:53:40 +0300 |
---|---|---|
committer | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2018-01-10 18:26:42 +0100 |
commit | 1921a70ab1a8761917bea8c74afaa790719fe958 (patch) | |
tree | 06a50bc2633ce329e5ddcff5fb03b514a9d4837d | |
parent | f0eecc6a4f541838e9930c98bc982546f65c7a4f (diff) |
Revert "Remove the --cleanDestinationDir flag", there is a better fix.
This reverts commit 768ec5df9fa8f91610ee80a9e6194f94a7dbe117.
-rw-r--r-- | commands/hugo.go | 5 | ||||
-rw-r--r-- | hugolib/config.go | 1 |
2 files changed, 6 insertions, 0 deletions
diff --git a/commands/hugo.go b/commands/hugo.go index 01afaaa4c..0e7b755f7 100644 --- a/commands/hugo.go +++ b/commands/hugo.go @@ -237,6 +237,7 @@ func initRootPersistentFlags() { // initHugoBuildCommonFlags initialize common flags related to the Hugo build. // Called by initHugoBuilderFlags. func initHugoBuildCommonFlags(cmd *cobra.Command) { + cmd.Flags().Bool("cleanDestinationDir", false, "remove files from destination not found in static directories") cmd.Flags().BoolP("buildDrafts", "D", false, "include content marked as draft") cmd.Flags().BoolP("buildFuture", "F", false, "include content with publishdate in the future") cmd.Flags().BoolP("buildExpired", "E", false, "include expired content") @@ -483,6 +484,7 @@ func createLogger(cfg config.Provider) (*jww.Notepad, error) { func (c *commandeer) initializeFlags(cmd *cobra.Command) { persFlagKeys := []string{"debug", "verbose", "logFile"} flagKeys := []string{ + "cleanDestinationDir", "buildDrafts", "buildFuture", "buildExpired", @@ -722,6 +724,9 @@ func (c *commandeer) copyStaticTo(dirs *src.Dirs, publishDir string) (uint64, er syncer.NoChmod = c.Cfg.GetBool("noChmod") syncer.SrcFs = fs syncer.DestFs = c.Fs.Destination + // Now that we are using a unionFs for the static directories + // We can effectively clean the publishDir on initial sync + syncer.Delete = c.Cfg.GetBool("cleanDestinationDir") if syncer.Delete { c.Logger.INFO.Println("removing all files from destination that don't exist in static dirs") diff --git a/hugolib/config.go b/hugolib/config.go index ce0f5bac9..8e06d3e8e 100644 --- a/hugolib/config.go +++ b/hugolib/config.go @@ -164,6 +164,7 @@ func loadDefaultSettingsFor(v *viper.Viper) error { return err } + v.SetDefault("cleanDestinationDir", false) v.SetDefault("watch", false) v.SetDefault("metaDataFormat", "toml") v.SetDefault("disable404", false) |