
# --- Scenario 1: Without static directory ---

cpr golden_public public

hugo
tree public
cmp stdout no_static_default_build.txt

hugo --cleanDestinationDir
tree public
cmp stdout no_static_clean_build.txt

# --- Scenario 2: With static directory ---

rm public

cpr golden_public public
cpr golden_static static

hugo
tree public
cmp stdout with_static_default_build.txt

hugo --cleanDestinationDir
tree public
cmp stdout with_static_clean_build.txt

# --- Scenario 3: Type mismatch between destination and static ---

rm public static

cpr golden_public_mismatch public
cpr golden_static_mismatch static

hugo --cleanDestinationDir
tree public
cmp stdout mismatch_clean_build.txt

# --- Scenario 4: Custom keepFiles and keepDirs ---

rm public static

cpr golden_public_keep public

hugo --config hugo_keep.toml
tree public
cmp stdout keep_clean_build.txt

# --- Scenario 5: Negated keepFiles ---

rm public

cpr golden_public_keep public

hugo --config hugo_keep_negate.toml
tree public
cmp stdout keep_negate_clean_build.txt

# --- Scenario 6: Deprecated root cleanDestinationDir key with default keep patterns ---

rm public

cpr golden_public_keep public

hugo --config hugo_legacy.toml
tree public
cmp stdout legacy_clean_build.txt

# Files

-- hugo.toml --
disableKinds = ['page','rss','section','sitemap','taxonomy','term']
-- hugo_keep.toml --
disableKinds = ['page','rss','section','sitemap','taxonomy','term']
[build.cleanDestinationDir]
enable = true
keepFiles = ['.domains', '_redirects']
keepDirs = ['keep-me']
-- hugo_keep_negate.toml --
disableKinds = ['page','rss','section','sitemap','taxonomy','term']
# Render home as JSON so no HTML gets rendered.
[outputs]
home = ['json']
[build.cleanDestinationDir]
enable = true
# Remove all HTML files, keep everything else.
keepFiles = ['! **.html']
-- hugo_legacy.toml --
disableKinds = ['page','rss','section','sitemap','taxonomy','term']
cleanDestinationDir = true
-- content/_index.md --
---
title: home
---
-- layouts/home.html --
{{ .Title }}
-- layouts/home.json --
{{ .Title | jsonify }}

-- golden_public/.dir-a/a.txt --
-- golden_public/.b.txt --
-- golden_public/.git --
-- golden_public/.gitattributes --
-- golden_public/.gitignore --
-- golden_public/c.txt --
-- golden_public/dir-b/.dir-c/d.txt --
-- golden_public/dir-b/.e.txt --
-- golden_public/dir-b/.git --
-- golden_public/dir-b/.gitignore --
-- golden_public/dir-b/f.txt --
-- golden_public/dir-d/g.txt --
-- golden_public/dir-e/.dir-f/h.txt --
-- golden_public/dir-e/.i.txt --
-- golden_public/dir-e/.gitattributes --
-- golden_public/dir-e/j.txt --

-- golden_static/.k.txt --
-- golden_static/l.txt --
-- golden_static/dir-e/.m.txt --
-- golden_static/dir-e/n.txt --

-- golden_public_keep/.domains --
-- golden_public_keep/.gitignore --
-- golden_public_keep/.hidden/x.txt --
-- golden_public_keep/_redirects --
-- golden_public_keep/a.html --
-- golden_public_keep/b.txt --
-- golden_public_keep/dir/.domains --
-- golden_public_keep/keep-me/x.html --
-- golden_public_keep/keep-me/y.txt --

-- golden_public_mismatch/type-a/x.txt --
-- golden_public_mismatch/type-b --

-- golden_static_mismatch/type-a --
-- golden_static_mismatch/type-b/y.txt --

-- no_static_default_build.txt --
.
└─.b.txt
└─.dir-a/
  └─a.txt
└─.git
└─.gitattributes
└─.gitignore
└─c.txt
└─dir-b/
  └─.dir-c/
    └─d.txt
  └─.e.txt
  └─.git
  └─.gitignore
  └─f.txt
└─dir-d/
  └─g.txt
└─dir-e/
  └─.dir-f/
    └─h.txt
  └─.gitattributes
  └─.i.txt
  └─j.txt
└─index.html
-- no_static_clean_build.txt --
.
└─.dir-a/
  └─a.txt
└─.git
└─.gitattributes
└─.gitignore
└─dir-b/
  └─.dir-c/
    └─d.txt
  └─.git
  └─.gitignore
└─dir-e/
  └─.dir-f/
    └─h.txt
  └─.gitattributes
└─index.html
-- with_static_default_build.txt --
.
└─.b.txt
└─.dir-a/
  └─a.txt
└─.git
└─.gitattributes
└─.gitignore
└─.k.txt
└─c.txt
└─dir-b/
  └─.dir-c/
    └─d.txt
  └─.e.txt
  └─.git
  └─.gitignore
  └─f.txt
└─dir-d/
  └─g.txt
└─dir-e/
  └─.dir-f/
    └─h.txt
  └─.gitattributes
  └─.i.txt
  └─.m.txt
  └─j.txt
  └─n.txt
└─index.html
└─l.txt
-- with_static_clean_build.txt --
.
└─.dir-a/
  └─a.txt
└─.git
└─.gitattributes
└─.gitignore
└─.k.txt
└─dir-b/
  └─.dir-c/
    └─d.txt
  └─.git
  └─.gitignore
└─dir-e/
  └─.dir-f/
    └─h.txt
  └─.gitattributes
  └─.m.txt
  └─n.txt
└─index.html
└─l.txt
-- mismatch_clean_build.txt --
.
└─index.html
└─type-a
└─type-b/
  └─y.txt
-- keep_clean_build.txt --
.
└─.domains
└─_redirects
└─index.html
└─keep-me/
  └─x.html
  └─y.txt
-- keep_negate_clean_build.txt --
.
└─.domains
└─.gitignore
└─.hidden/
  └─x.txt
└─_redirects
└─b.txt
└─dir/
  └─.domains
└─index.json
└─keep-me/
  └─y.txt
-- legacy_clean_build.txt --
.
└─.gitignore
└─.hidden/
  └─x.txt
└─index.html
