Preserve Node tool-manager shim names during native installation

This commit is contained in:
2026-11-08 16:54:17 +00:00
parent fdc411716f
commit bd9509b744
2 changed files with 18 additions and 1 deletions
+3 -1
View File
@@ -333,7 +333,9 @@ class Setup:
return target
def configure_web(self, prefix, args, web_build=None):
node = str(Path(shutil.which("node")).resolve())
# Tool-manager shims dispatch by their invoked name (for example Volta).
# Resolving the symlink would run volta-shim instead of node.
node = str(Path(shutil.which("node")).absolute())
version = self.runner([node, "--version"], capture_output=True, text=True)
try:
major = int(version.stdout.strip().removeprefix("v").split(".")[0])
+15
View File
@@ -296,6 +296,21 @@ class SetupNativeTests(unittest.TestCase):
installer.configure_web(Path(directory) / "prefix", setup_native.arguments([]))
self.assertEqual(auth.read_text(), '{"password":"short"}')
def test_node_tool_manager_shim_keeps_its_invoked_name(self):
with tempfile.TemporaryDirectory() as directory:
recorder = Recorder()
installer = self.installer(directory, recorder)
prefix = Path(directory) / "prefix"
installer.prepare_layout(prefix)
target = Path(directory) / "tool-manager-shim"
target.write_text("fixture")
shim = Path(directory) / "node"
shim.symlink_to(target)
with patch.object(setup_native.shutil, "which", return_value=str(shim)):
web = installer.configure_web(prefix, setup_native.arguments([]))
self.assertEqual(web["node"], str(shim))
self.assertIn([str(shim), "--version"], recorder.calls)
def test_old_node_is_rejected(self):
with tempfile.TemporaryDirectory() as directory:
def old_node(command, **kwargs):