fix(cli): widen Windows .bat wrapper fix to custom-name alias path

The profile alias --name path in main.py rewrote the wrapper with a
hardcoded #!/bin/sh script right after create_wrapper_script(), clobbering
the .bat on Windows and reintroducing the exact bug for custom aliases.

create_wrapper_script() now takes an optional target so the alias file is
named after the alias while the -p content references the profile — one
platform-aware code path, no post-hoc rewrite.
This commit is contained in:
teknium1
2026-05-29 12:32:47 -07:00
committed by Teknium
parent 6312dd8c3a
commit 8836b3a113
3 changed files with 37 additions and 7 deletions
+26
View File
@@ -682,6 +682,32 @@ class TestWrapperScript:
from hermes_cli.profiles import remove_wrapper_script
assert remove_wrapper_script("nonexistent") is False
def test_custom_alias_target_on_posix(self, profile_env, monkeypatch):
# Custom alias name pointing at a differently-named profile: the file
# is named after the alias, the -p content references the profile.
monkeypatch.setattr("sys.platform", "darwin")
from hermes_cli.profiles import create_wrapper_script
wrapper = create_wrapper_script("rq", target="redqueen")
assert wrapper is not None
assert wrapper.name == "rq"
content = wrapper.read_text()
assert content.startswith("#!/bin/sh")
assert "hermes -p redqueen" in content
def test_custom_alias_target_on_windows(self, profile_env, monkeypatch):
# Regression: custom-name aliases must still produce an executable
# .bat (not a clobbered #!/bin/sh) on Windows.
monkeypatch.setattr("sys.platform", "win32")
from hermes_cli.profiles import create_wrapper_script
wrapper = create_wrapper_script("rq", target="redqueen")
assert wrapper is not None
assert wrapper.name == "rq.bat"
content = wrapper.read_text()
assert "@echo off" in content
assert "hermes -p redqueen" in content
assert "%*" in content
assert "#!/bin/sh" not in content
# ===================================================================
# TestRenameProfile