Skip to content

Instantly share code, notes, and snippets.

@moomoohk
Created April 7, 2015 12:55
Show Gist options
  • Save moomoohk/f3b114c392aae03f0cd2 to your computer and use it in GitHub Desktop.
Save moomoohk/f3b114c392aae03f0cd2 to your computer and use it in GitHub Desktop.
Cactus (http://cactusformac.com/) plugin that generates an external build folder that doesn't overwrite your git files. Perfect for usage with GitHub pages, just stick your .git in the generated build folder.
import distutils.dir_util
import shutil
import os
def copytree(src, dst):
for item in os.listdir(src):
s, d = os.path.join(src, item), os.path.join(dst, item)
if os.path.isdir(s):
shutil.copytree(s, d, False, None)
else:
shutil.copy2(s, d)
def postBuild(site):
build_folder = site._path + "/build"
for sub_file in os.listdir(build_folder):
if sub_file[0] != ".":
sub_file_path = os.path.join(build_folder, sub_file)
try:
if os.path.isfile(sub_file_path):
os.unlink(sub_file_path)
elif os.path.isdir(sub_file_path):
shutil.rmtree(sub_file_path)
except Exception, e:
print e
copytree(site.build_path, build_folder)
@moomoohk
Copy link
Author

moomoohk commented May 2, 2015

Gotcha! Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment