From 62fecb39e47ddbd283181d141c2332c06ce2fb21 Mon Sep 17 00:00:00 2001 From: sofisl <55454395+sofisl@users.noreply.github.com> Date: Wed, 29 Nov 2023 14:20:06 -0800 Subject: [PATCH] fix(node-mono-repo): execute non-ESM compileProtos command when not ESM (#1906) * fix(node): ensure compileProtos is run normally if not esm --- synthtool/languages/node_mono_repo.py | 2 +- tests/test_node_mono_repo.py | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/synthtool/languages/node_mono_repo.py b/synthtool/languages/node_mono_repo.py index 74191d2c1..4ab6eaeb2 100644 --- a/synthtool/languages/node_mono_repo.py +++ b/synthtool/languages/node_mono_repo.py @@ -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"] ) diff --git a/tests/test_node_mono_repo.py b/tests/test_node_mono_repo.py index c91373878..d8e0fb0a6 100644 --- a/tests/test_node_mono_repo.py +++ b/tests/test_node_mono_repo.py @@ -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()