Skip to content

Commit

Permalink
Enforce LF when packing
Browse files Browse the repository at this point in the history
  • Loading branch information
Willy-JL committed Oct 27, 2024
1 parent 948dd56 commit 8854ee9
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions .utils/ext/asset_packer.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ def convert_bmx(img: "Image.Image | pathlib.Path") -> bytes:
return data


def copy_file_as_lf(src: "pathlib.Path", dst: "pathlib.Path"):
dst.write_bytes(src.read_bytes().replace(b"\r\n", b"\n"))


def pack_anim(src: pathlib.Path, dst: pathlib.Path):
if not (src / "meta.txt").is_file():
return
Expand All @@ -53,7 +57,7 @@ def pack_anim(src: pathlib.Path, dst: pathlib.Path):
if not frame.is_file():
continue
if frame.name == "meta.txt":
shutil.copyfile(frame, dst / frame.name)
copy_file_as_lf(frame, dst / frame.name)
elif frame.name.startswith("frame_"):
if frame.suffix == ".png":
(dst / frame.with_suffix(".bm").name).write_bytes(convert_bm(frame))
Expand Down Expand Up @@ -145,7 +149,7 @@ def pack(

if (source / "Anims/manifest.txt").exists():
(packed / "Anims").mkdir(parents=True, exist_ok=True)
shutil.copyfile(
copy_file_as_lf(
source / "Anims/manifest.txt", packed / "Anims/manifest.txt"
)
manifest = (source / "Anims/manifest.txt").read_bytes()
Expand Down

0 comments on commit 8854ee9

Please sign in to comment.