Skip to content

Commit 39f5ce8

Browse files
committed
Fix: clean output folders
1 parent d454d33 commit 39f5ce8

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

  • components/rsptx/build_tools

components/rsptx/build_tools/core.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import datetime
1616
import os
1717
import re
18+
import shutil
1819
import subprocess
1920
from pathlib import Path
2021
import logging
@@ -186,6 +187,11 @@ def _build_ptx_book(config, gen, manifest, course, click=click, target="runeston
186187
logger.addHandler(string_io_handler)
187188
if hasattr(click, "worker"):
188189
click.add_logger(logger)
190+
# clean out the output directory
191+
pdb.set_trace()
192+
if rs.output_dir_abspath().exists():
193+
shutil.rmtree(rs.output_dir_abspath())
194+
189195
click.echo("Building the book")
190196
if gen:
191197
click.echo("Generating assets")
@@ -208,6 +214,10 @@ def _build_ptx_book(config, gen, manifest, course, click=click, target="runeston
208214

209215
click.echo(f"Book will be deployed to {book_path}")
210216
if rs.output_dir_abspath() != book_path:
217+
if book_path.exists():
218+
# clean out the published directory so it is a clone of the output directory
219+
# This ensures we don't have old bits of webpack junk lingering
220+
shutil.rmtree(book_path)
211221
res = copytree(rs.output_dir_abspath(), book_path, dirs_exist_ok=True)
212222
if not res:
213223
click.echo("Error copying files to published")
@@ -331,7 +341,7 @@ def check_project_ptx(click=click, course=None, target="runestone"):
331341
tgt.output_dir = Path(docid)
332342

333343
tgt.stringparams.update({"host-platform": "runestone"})
334-
344+
335345
return tgt
336346

337347

0 commit comments

Comments
 (0)