Created
April 7, 2015 12:55
-
-
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@moomoohk Cactus for Mac ≠ Cactus.
The later is the static website generator that works via the command line and is used by Cactus for Mac.
The latest version of Cactus is v3.0.2, well according to the commit, its not yet in the releases.