Skip to content

Commit

Permalink
fix(node-mono-repo): execute non-ESM compileProtos command when not E…
Browse files Browse the repository at this point in the history
…SM (#1906)

* fix(node): ensure compileProtos is run normally if not esm
  • Loading branch information
sofisl authored Nov 29, 2023
1 parent 9367caa commit 62fecb3
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
2 changes: 1 addition & 1 deletion synthtool/languages/node_mono_repo.py
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ def compile_protos_hermetic(relative_dir, is_esm=False, hide_output=False):
"""
logger.debug("Compiling protos...")
command = (
[f"{_TOOLS_DIRECTORY}/node_modules/.bin/compileProtos", "esm/src", "--esm"]
[f"{_TOOLS_DIRECTORY}/node_modules/.bin/compileProtos", "src"]
if not is_esm
else [f"{_TOOLS_DIRECTORY}/node_modules/.bin/compileProtos", "esm/src", "--esm"]
)
Expand Down
22 changes: 22 additions & 0 deletions tests/test_node_mono_repo.py
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,28 @@ def test_compile_protos_esm(self, shell_run_mock):
]
)

@patch("synthtool.shell.run")
def test_compile_protos_hermetic(self, shell_run_mock):
node_mono_repo.compile_protos_hermetic(relative_dir="any", is_esm=False)
calls = shell_run_mock.call_args_list
assert any(
[
"/node_modules/.bin/compileProtos src" in " ".join(call[0][0])
for call in calls
]
)

@patch("synthtool.shell.run")
def test_compile_protos_hermetic_esm(self, shell_run_mock):
node_mono_repo.compile_protos_hermetic(relative_dir="any", is_esm=True)
calls = shell_run_mock.call_args_list
assert any(
[
"/node_modules/.bin/compileProtos esm/src --esm" in " ".join(call[0][0])
for call in calls
]
)

@patch("synthtool.shell.run")
def test_postprocess_gapic_library(self, shell_run_mock):
node_mono_repo.postprocess_gapic_library()
Expand Down

0 comments on commit 62fecb3

Please sign in to comment.