Skip to content

Commit

Permalink
Don't delete hidden files or directories with --clean
Browse files Browse the repository at this point in the history
  • Loading branch information
d0ugal committed Apr 4, 2015
1 parent ce3d5c6 commit f488e75
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions mkdocs/utils.py
Expand Up @@ -37,13 +37,21 @@ def clean_directory(directory):
"""
Remove the content of a directory recursively but not the directory itself.
"""
if os.path.exists(directory):
for entry in os.listdir(directory):
path = os.path.join(directory, entry)
if os.path.isdir(path):
shutil.rmtree(path, True)
else:
os.unlink(path)
if not os.path.exists(directory):
return

for entry in os.listdir(directory):

# Don't remove hidden files from the directory. We never copy files
# that are hidden, so we shouldn't delete them either.
if entry.startswith('.'):
continue

path = os.path.join(directory, entry)
if os.path.isdir(path):
shutil.rmtree(path, True)
else:
os.unlink(path)


def copy_media_files(from_dir, to_dir):
Expand Down

0 comments on commit f488e75

Please sign in to comment.