implement option to prune old files in build directory
This commit is contained in:
parent
bfd0f6e01b
commit
f5a5ad6328
1 changed files with 12 additions and 0 deletions
|
@ -130,6 +130,18 @@ def build(
|
|||
for info in infos:
|
||||
info_dict['tex_sources'].append(info)
|
||||
|
||||
built_files = [info['name'] for info in info_dict['tex_sources']]
|
||||
if last_build_info:
|
||||
lastly_built_files = [info['name'] for info in last_build_info['tex_sources']]
|
||||
else:
|
||||
lastly_built_files = []
|
||||
if clean_old_files:
|
||||
for file in output_dir.rglob('*'):
|
||||
if str(file.relative_to(output_dir)) in lastly_built_files:
|
||||
if str(file.relative_to(output_dir)) not in built_files:
|
||||
print(f'[PyTeX] Removing old built file {str(file.relative_to(output_dir))}')
|
||||
file.unlink()
|
||||
|
||||
if write_build_information:
|
||||
with open(output_dir / 'build_info.json', 'w') as f:
|
||||
json.dump(info_dict, f, indent=4)
|
||||
|
|
Loading…
Reference in a new issue