Skip to content

Commit

Permalink
handle package.json version string in build.py
Browse files Browse the repository at this point in the history
  • Loading branch information
fzumstein committed May 20, 2024
1 parent f448451 commit f44d4d4
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions xlwingsjs/build.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import argparse
import os
import re
import shutil
import subprocess
from pathlib import Path
from shlex import split
from textwrap import dedent

this_dir = Path(__file__).resolve().parent
root_dir = this_dir.parent
os.chdir(this_dir)

target_dir = "dist"
Expand Down Expand Up @@ -79,6 +81,20 @@ def build(version):
)
Path(webpack_config).write_text(content)

# Bump package.json
file_path = root_dir / "package.json"
with open(file_path, "r") as file:
lines = file.readlines()

with open(file_path, "w") as file:
for line in lines:
line = re.sub(
r'"version": "\d+\.\d+\.\d+"',
f'"version": "{version}"',
line,
)
file.write(line)


if __name__ == "__main__":
parser = argparse.ArgumentParser()
Expand Down

0 comments on commit f44d4d4

Please sign in to comment.