Skip to content

Commit c4d5644

Browse files
committed
fix: windows execute
1 parent 8cf28c2 commit c4d5644

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

slack_cli_hooks/hooks/get_hooks.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@
77
PROTOCOL: Protocol
88

99
# Wrap sys.executable in quotes to prevent execution failures if a white space is present in the absolute python path
10-
EXEC = f"'{sys.executable}'" if sys.executable else "python"
10+
if sys.executable:
11+
EXEC = f"& '{sys.executable}'" if sys.platform == "win32" else f"'{sys.executable}'"
12+
else:
13+
EXEC = "python"
1114

1215

1316
hooks_payload = {

tests/slack_cli_hooks/hooks/test_get_hooks.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,15 @@
88

99
class TestGetHooks:
1010
def test_exec_uses_sys_executable(self):
11-
with patch.object(sys, "executable", "/usr/bin/python3"):
11+
with patch.object(sys, "executable", "/usr/bin/python3"), patch.object(sys, "platform", "linux"):
1212
importlib.reload(get_hooks)
1313
assert get_hooks.EXEC == "'/usr/bin/python3'"
1414

15+
def test_exec_uses_call_operator_on_windows(self):
16+
with patch.object(sys, "executable", "C:\\Python\\python.exe"), patch.object(sys, "platform", "win32"):
17+
importlib.reload(get_hooks)
18+
assert get_hooks.EXEC == "& 'C:\\Python\\python.exe'"
19+
1520
def test_exec_falls_back_to_python_when_sys_executable_is_empty(self):
1621
with patch.object(sys, "executable", ""):
1722
importlib.reload(get_hooks)

0 commit comments

Comments
 (0)