Skip to content

Commit

Permalink
improve static file replacement; use nojekyll (#674)
Browse files Browse the repository at this point in the history
  • Loading branch information
oscarlevin authored Jan 28, 2024
1 parent d78459a commit 083cfce
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
10 changes: 10 additions & 0 deletions pretext/core/resources.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from pathlib import Path
import zipfile
import importlib.resources
import shutil
from .. import CORE_COMMIT


Expand All @@ -21,6 +22,15 @@ def path(*args: str) -> Path:


def install(local_base_path: Path) -> None:
backup_dir = local_base_path.with_name(local_base_path.name + ".bak")
if Path.is_dir(backup_dir):
# remove old backup:
shutil.rmtree(backup_dir)
if Path.is_dir(local_base_path):
print(f"Backing up old static files to {backup_dir}")
Path.rename(local_base_path, backup_dir)
Path.mkdir(local_base_path)

with importlib.resources.path("pretext.core", "resources.zip") as static_zip:
with zipfile.ZipFile(static_zip, "r") as zip:
zip.extractall(local_base_path)
Expand Down
2 changes: 1 addition & 1 deletion pretext/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -576,7 +576,7 @@ def publish_to_ghpages(directory: Path, update_source: bool) -> None:
ghp_import.ghp_import(
directory,
mesg="Latest build deployed.",
nojekyll=False,
nojekyll=True,
)
log.info(f"Attempting to connect to remote repository at `{origin.url}`...")
# log.info("(Your SSH password may be required.)")
Expand Down

0 comments on commit 083cfce

Please sign in to comment.