nat-n / poethepoet

A task runner that works well with poetry.
https://poethepoet.natn.io/
MIT License
1.4k stars 58 forks source link

win32: Resolve Executable to Absolute Path if not found in venv #142

Closed ameily closed 1 year ago

ameily commented 1 year ago

This PR addresses #119 for cmd tasks that use the poetry executor. I found that, on Windows, a task like the following wasn't working:

[tool.poe.tasks]
"check-spelling" = "npx cspell README.md CHANGELOG.md"

Running the task on Windows is failing because npx does not exist, it's actually npx.cmd:

poetry run poe check-spelling
# ..snip..
FileNotFoundError: [WinError 2] The system cannot find the file specified

The problem seems to be that the fix for #119 was done in PoeExecutor.execute, however this isn't called by the poetry executor since it calls PoeExecutor._execute_cmd() directly, bypassing the fix. I've confirmed that this PR works for my case.