Skip to content

Commit 0992ad5

Browse files
authored
Fix updating of MODULE.bazel in update_bazel_workspace.py (#1550)
The regex was not matching which caused #1549 to fail.
1 parent ed2035a commit 0992ad5

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

scripts/update_bazel_workspace.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,11 @@ def update_module_version(version):
6464
with open(BAZEL_MODULE_FILE, 'r') as f:
6565
content = f.read()
6666

67-
content = re.sub(
68-
r'module\(name = "emsdk", version = "\d+.\d+.\d+"\)',
69-
f'module(name = "emsdk", version = "{version}")',
70-
content)
67+
pattern = '(module\(\s*name = "emsdk",\s*version = )"\d+.\d+.\d+",\n\)'
68+
# Verify that the pattern exists in the input since re.sub will
69+
# will succeed either way.
70+
assert re.search(pattern, content)
71+
content = re.sub(pattern, fr'\1"{version}",\n)', content)
7172

7273
with open(BAZEL_MODULE_FILE, 'w') as f:
7374
f.write(content)

0 commit comments

Comments
 (0)